(10-05-2024, 04:31 AM)NakedApe Wrote: @SMcNeill Steve, I know that "##" means _float as it relates to a variable, but what does the double hashtag do in your example code here? I've never seen that.
V2D = (360## + _R2D(_Atan2(Vx, Vy))) Mod 360##
Thanks.
It defines my constant as being a float in this case. Sometimes, it can make a world of difference in math. Let me showcase the simplest example that I can think of for you:
Code: (Select All)
For i = 1 To 10
Print Using "#.######### #.####################### #.#######################"; 1! / i, 1# / i, 1## / i
Next
Quote:1.000000000 1.00000000000000000000000 1.00000000000000000000000
0.500000000 0.50000000000000000000000 0.50000000000000000000000
0.333333343 0.33333333333333331482962 0.33333333333333333334237
0.250000000 0.25000000000000000000000 0.25000000000000000000000
0.200000003 0.20000000000000001110223 0.20000000000000000000271
0.166666672 0.16666666666666665741481 0.16666666666666666667118
0.142857149 0.14285714285714284921269 0.14285714285714285714092
0.125000000 0.12500000000000000000000 0.12500000000000000000000
0.111111112 0.11111111111111110494321 0.11111111111111111110961
0.100000001 0.10000000000000000555112 0.10000000000000000000136
Notice the difference in those values? Look at the right side of the number and it should be fairly obvious.
QB64 tries to return type values to you based on what it thinks is best.
SINGLE / SINGLE = SINGLE
SINGLE / DOUBLE = DOUBLE
SINGLE / FLOAT = FLOAT
(or actually my types are reversed above, but you get the point.
)
By specifying 360##, I'm making my math return results as a FLOAT, rather than limiting them to the precision of a Single or Double.
1& <-- a long number, with the value of 1.
1! <-- a SINGLE number, with the value of 1.
1## <-- a FLOAT number, with the value of 1.
Depending on what we're doing with them, the TYPE might affect the outcome of the calculations for us.