fork download
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4. #include <cmath>
  5.  
  6. int main()
  7. {
  8. double x = 0.5; // linear to frequency conversion
  9.  
  10. const double d = 3.0; // decades per scale
  11. const double ten2d = std::pow (10, d);
  12. std::cout << x << "\n";
  13.  
  14. x = (std::pow (ten2d, x) - 1) / (ten2d - 1);
  15. std::cout << x << "\n";
  16.  
  17. x = 20.0 + (20000.0 - 20.0) * x;
  18. std::cout << x << "\n";
  19.  
  20. x = (x - 20.0) / (20000.0 - 20.0);
  21. std::cout << x << "\n";
  22.  
  23. x = (std::log10 ((x * (ten2d - 1)) + 1)) / std::log10 (ten2d); // inverse
  24. std::cout << x << "\n";
  25.  
  26.  
  27. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
0.5
0.0306534
632.456
0.0306534
0.5