JSFX: Rounding discrepancy between MacOS and Windows
Some parameter values are shown incorrectly when drawing them on display on a JSFX plugin on REAPER for MacOS.
For example:
Code:
value = 0.03;
gfx_drawstr( sprintf(#value,"%g", value ) );
Shows on display as "0.0299999".
Screenshot attached, as well as a small JS plugin to demonstrate the issue. It will probably not show any issues on Windows, but on MacOS as you drag the slider that moves in 0.01 increments, some values are drawn just short of the actual value.
__________________
______Announcing__mrelwood plugins______
.. MacBook Pro 16" Late '19 .. Scarlett 6i6, Saffire Pro 24 DSP (+ADA8000) .. FCA610 .. EVE SC207 .. Focal: Shape 65, Alpha 65, CMS 40, Listen Pro ..
I'm not really sure, but I don't think that's FPU rounding, but rather the difference in printf() implementation between MSVC and GCC/Clang.
For the case of printf("%g",.3), it appears to be -- the MSVC version doesn't depend on the FP rounding flag, whereas the macOS/linux versions do (restoring the FP rounding state to nearest before calling snprintf() makes macOS output 0.3, at least). This should be fixed in +dev0713...
I'm imagining there's some script out there that uses sprintf() to figure out what OS it is running on, oops.
For the case of printf("%g",.3), it appears to be -- the MSVC version doesn't depend on the FP rounding flag, whereas the macOS/linux versions do (restoring the FP rounding state to nearest before calling snprintf() makes macOS output 0.3, at least). This should be fixed in +dev0713...
Fix confirmed, and for e.g. printf("%.1f", 0.49) as well (before: 0.4; now: 0.5). And thanks for the info!
Quote:
Originally Posted by Justin
I'm imagining there's some script out there that uses sprintf() to figure out what OS it is running on, oops.
Yeah, maybe... However, I would rather have consistent printf(), YMMV. Also, you could always add another method/system variable to detect the OS, should this be an actual issue for anyone.