-
Notifications
You must be signed in to change notification settings - Fork 168
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
f64 only mode #452
Comments
It is not as simple as just parsing all integer literals as
It is possible, however, to overload the division operator as well as certain math functions. For example, we can always overload The user, however, may be surprised that a division turns the number into floating-point. |
Alternatively, we can allow you to set a mapper function into the Internall, Rhai already has facilities to set such a mapper function; it is just not exposed publicly. |
Thanks for the answer |
You can pull from https://github.com/rhaiscript/rhai and get the version with Remember to pull in the |
that works perfectly, thanks |
I'm using rhai as a glorified calculator inside a somewhat popular telegram bot (#69 ), the problem is that the hard distinction between integer and float types that rhai has, is making the language hard to use
It would be cool to have an option where you can make
10 / 9
orsqrt(2)
and obtain the correct floating point result instead of an1
or an errorI suppose this can be solved by having an option to treat all literals as f64 and parsing them as that
Using f64 exclusively does not give immediate problems (or at all) as noted in the lua documentation https://www.lua.org/pil/2.3.html
The text was updated successfully, but these errors were encountered: