You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
763B

  1. #include <iomanip>
  2. #include <cmath>
  3. #include "common.hpp"
  4. namespace rack_plugin_RJModules {
  5. std::stringstream format4display(float value){
  6. std::stringstream to_display;
  7. std::stringstream to_display2;
  8. float value_rounded = round(abs(10.0f * value))/10.0f;
  9. if (value_rounded < 1) {
  10. to_display << " " << std::setprecision(1) << std::setw(1) << std::fixed << value_rounded;
  11. }
  12. else if (value_rounded < 10) {
  13. to_display << " " << std::setprecision(2) << std::setw(3) << std::fixed << value_rounded;
  14. } else {
  15. to_display << std::setprecision(3) << std::setw(3) << std::fixed << value_rounded;
  16. }
  17. to_display2 << to_display.str().substr(0, 4);
  18. return to_display2;
  19. }
  20. } // namespace rack_plugin_RJModules