fork(2) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5.  
  6. const float EXPONENT = 1.8;
  7. const int INDEX_MAX = 15;
  8. int main(void) {
  9.  
  10. int pwmBaseValue = 255,pwmIndex = 15;
  11. int result = 0;
  12. float resultf = 0.0;
  13.  
  14. printf("Test = %f",pow(INDEX_MAX, EXPONENT));
  15. printf("\nTest2 = %f",(double)255*pow(INDEX_MAX, EXPONENT)/pow(INDEX_MAX, EXPONENT));
  16. resultf = pwmBaseValue * (pow(pwmIndex, EXPONENT));// / pow(INDEX_MAX, EXPONENT));
  17. result = resultf / pow(INDEX_MAX, EXPONENT);
  18. printf("\nResult1 = %i",result);
  19.  
  20. result = pow(pwmIndex, EXPONENT)/ pow(INDEX_MAX, EXPONENT)* pwmBaseValue;
  21. printf("\nResult2 = %f",result);
  22.  
  23. }
  24.  
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
Test = 130.907404
Test2 = 255.000000
Result1 = 254
Result2 = 255.000000