Yelay12 Posted July 14, 2024 Posted July 14, 2024 When Value of Type_DOUBLE divide with any number i get zero reminder. example, value = 43.0 divide by 2, get reminder is 0. I want to get reminder 1 in script for above example. How to do it. Please help.Thank.
kiynox Posted July 14, 2024 Posted July 14, 2024 [ @Yelay12 ] --- Quote When Value of Type_DOUBLE divide with any number i get zero reminder. First of all, what you want is modulo (%). t = 43.0 gg.alert(tostring(t % 2)) --- You need to understand that "DOUBLE" is floating-point number, thus you might need to convert it first into integer/non-precision number using "tonumber()" t = 43.2 gg.alert(tostring(tonumber(t) % 2)) --- Using "tonumber()" isn't really necessary, you can directly calculate it. Mine works: gg.searchNumber(43, gg.TYPE_DOUBLE) t = gg.getResults(1) if t ~= nil then gg.alert(tostring(t[1].value % 2)) end ---
Yelay12 Posted July 15, 2024 Author Posted July 15, 2024 12 hours ago, kiynox said: [ @Yelay12 ] --- First of all, what you want is modulo (%). t = 43.0 gg.alert(tostring(t % 2)) --- You need to understand that "DOUBLE" is floating-point number, thus you might need to convert it first into integer/non-precision number using "tonumber()" t = 43.2 gg.alert(tostring(tonumber(t) % 2)) --- Using "tonumber()" isn't really necessary, you can directly calculate it. Mine works: gg.searchNumber(43, gg.TYPE_DOUBLE) t = gg.getResults(1) if t ~= nil then gg.alert(tostring(t[1].value % 2)) end --- Thank bro for your replies.I will try this
Yelay12 Posted July 15, 2024 Author Posted July 15, 2024 12 hours ago, kiynox said: [ @Yelay12 ] --- First of all, what you want is modulo (%). t = 43.0 gg.alert(tostring(t % 2)) --- You need to understand that "DOUBLE" is floating-point number, thus you might need to convert it first into integer/non-precision number using "tonumber()" t = 43.2 gg.alert(tostring(tonumber(t) % 2)) --- Using "tonumber()" isn't really necessary, you can directly calculate it. Mine works: gg.searchNumber(43, gg.TYPE_DOUBLE) t = gg.getResults(1) if t ~= nil then gg.alert(tostring(t[1].value % 2)) end --- @kiynox bro i have another question for alert. gg.alert() function is running when above if condition even is false.Why? Please.Thank
Question
Yelay12
When Value of Type_DOUBLE divide with any number i get zero reminder.
example, value = 43.0 divide by 2, get reminder is 0.
I want to get reminder 1 in script for above example. How to do it. Please help.Thank.
3 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.