Re: [go-nuts] Why IF might not work

73 views
Skip to first unread message

Levieux Michel

unread,
Nov 23, 2021, 1:40:49 PM11/23/21
to Денис Мухортов, golang-nuts
I'm not going to point you directly at the solution as this is more of an issue with the way you're trying to solve this. But it's not because the result of your division is comprised between 1.0 and 2.0 that a number is a multiple of the other, especially with floating point numbers.  You might want to have a look at the math package, specifically the Mod function.

To give you another example, 15.0 / 10.0 is 1.5, so it passes your condition, though 15 is not a multiple of 10.

Hope this helps 

Le mar. 23 nov. 2021 à 19:19, Денис Мухортов <muhorto...@gmail.com> a écrit :
I want to collect subsets of numbers in increments of 10. All numbers pass if correctly, except 32.5. The result of its division is 1.625. But for some reason it passes if twice, I added different numbers, all work correctly
https://go.dev/play/p/kdJu-PBsbpC

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/07dcc809-6d21-4e60-9a0e-95514719bb4en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages