It sounds strange to me ... Is it supposed to be integer right ?
Because -1.0 and 1.0 are double. If you have a pure integer expression it will be calculated as integer. As soon as a double is involved it's a double expression. You have to get used to it. It's a bit different than some other languages where you need explicit casting.
Last edited by DarkDragon on Mon Jul 01, 2024 4:56 pm, edited 1 time in total.
; 50 %
a = 20
b = 50
Debug a / 100 * b ; Integer calculation error by the programmer.
Debug 1.0 * a / 100 * b ; Force to float
c = 1.0 * a / 100 * b ; Force to float and back integer
Debug c
c = a * b / 100 ; Correct integer calculation
Debug c
Last edited by mk-soft on Mon Jul 01, 2024 5:07 pm, edited 1 time in total.
Ok thanks all guys, never thought this casting for macro, it works here.
@mk-soft : #MAXDWORD has already declared from PB, impossible to assign a new value... sorry
But... without to assign to a new value it works your code !
@mk-soft : Strange this 1.0 * m_random_double() work as double
But r1.d = m_random_double() ... not same here for precision, it looks like more shorter than first
threedslider wrote: Mon Jul 01, 2024 5:07 pm
@mk-soft : #MAXDWORD has already declared from PB, impossible to assign a new value... sorry
But... without to assign to a new value it works your code !
#MAXDWORD is probably a Windows API constant. It does not exist under Linux or macOS
threedslider wrote: Mon Jul 01, 2024 5:11 pm
@mk-soft : Strange this 1.0 * m_random_double() work as double
But r1.d = m_random_double() ... not same here for precision, it looks like more shorter than first