-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FloatArray prevents rounding #1873
Comments
nothing strange. it has been discussed many times on the sc-users mailing list for example in the 'Strange modulo behavior' thread. |
Why not use an |
@telephon To avoid making a copy of a FloatArray from a SoundFile. |
@jamshark70 's explanation in #1874 clears it up. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0.02 Is a floating point number. However, if it is inside a FloatArray, that number will never be reached precisely, which can cause rounding errors.
a=FloatArray[0.1];
expected:
=> FloatArray[ 0.1 ]
actual:
=> FloatArray[ 0.10000000149012 ]
a[0] = a[0].round(0.01);
expected:
=> FloatArray[ 0.1 ]
actual:
=> FloatArray[ 0.10000000149012 ]
This works:
a[0].round(0.01);
=> 0.1
a[0].round(0.01).class;
=> Float
The text was updated successfully, but these errors were encountered: