Cycling74 / rnbo.example.vcvrack

An example of using RNBO exports in VCV Rack plugins
GNU General Public License v3.0
27 stars 1 forks source link

implicit conversion from 'int' to 'float' changes value #3

Closed giuliomoro closed 1 year ago

giuliomoro commented 2 years ago

when building rnbo code with -DRNBO_USE_FLOAT32 you get

rnbo/common/RNBO_AudioSignal.h:82:27: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]

Fix the warning with an explicit cast to number:

index 8afd5ed..5ef29f0 100644
--- a/rnbo/common/RNBO_AudioSignal.h
+++ b/rnbo/common/RNBO_AudioSignal.h
@@ -79,7 +79,7 @@ namespace RNBO {

        static inline number rand01()
        {
-               return number(rand()) / RAND_MAX;
+               return number(rand()) / number(RAND_MAX);
        }

        static inline float bitwiseFloat(unsigned long n)
isabelgk commented 1 year ago

Thanks for the report @giuliomoro -- I'll make a note of this to fix it up. As in #1 , please report future generalized RNBO questions/feature requests/bug reports/etc to support@cycling74.com or the forums.