-
Notifications
You must be signed in to change notification settings - Fork 66
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
odd negative sign in modulo results #109
Comments
It is the result of a modulo calculation on the floating-point numbers, since the result of the CEIL function is a float. However, it may be a bad idea to apply the % operator to float. As a workaround, you can avoid that result by explicitly converting the ceil result to integer.
|
@mithrandie I don't get it, even for floats If you use math.Mod behind the scenes, the result could be negative if
|
After verification, I'm wrong about "standard". There is no such thing about the sign of modulo. In some languages (like go and javascript) the sign of But in any case, if And in any case, it will be good to document the behavior of |
@mithrandie You use math.Remainder instead of |
Ah, I didn't know there was the math.Mod function... |
hi @mithrandie and @kpym Thanks so much for the insights! For myself, i am not blocked since we are using it for analysis internally; no huge repercussions with the negative sign. I will give the suggestion here a try too. I'll leave this open since it'd be nice to close this if a patch is on the way 🤓 |
hi @mithrandie I've leave it to you, if you'd like to keep this open, given #109 (comment) |
Hi!
firstly, thank you so much for this tool.
It's been amazingly helpful for me 🙇 .
I wanted to file an issue about seeing negative values in the modulo (
%
) result.To reproduce:
I was expecting 37 there since
CEIL(13041/60) = 217
and217 % 60 = 37
, not-23
.I am thinking this is a possible bug 🤔
The text was updated successfully, but these errors were encountered: