grain
grain copied to clipboard
Modulo Throws Misleading Error When Used On A Float
In the image above i was using modulo and my Number value became a float, when i used modolo it gave me the error of NumberNotIntlike: Can't coerce number to integer it would be nice if either modulo worked on floats or an error was given stating something like Modulo Doesn't Currently Support Floating Point Values as the Number types goal is to be user firendly the NumbernotIntLike can be a little confusing and misleading to newer developers
Defining modulo for floats/rationals might be reasonable behavior here instead of throwing an error. Here's what Python does:
Python 3.10.5 (v3.10.5:f377153967, Jun 6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 3.5 % 3
0.5
>>> 2/3 % 3
0.6666666666666666
cc @peblair
js does the same thing
% in JS is remainder rather than modulo, so it makes a little more sense there.