Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spinner Game Demo
#21
@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.
Reply
#22
(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. Tongue )

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.
Reply
#23
Got it. Thanks! Smile And +1 for the private lesson. Wink
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Menu Demo to be Expanded Pete 29 1,607 01-31-2026, 11:08 PM
Last Post: Pete
  A new and Exciting Demo! Cobalt 1 598 05-23-2025, 09:55 PM
Last Post: Pete
Tongue My 1st Demo BloodyHash 1 780 05-19-2024, 10:22 PM
Last Post: JRace

Forum Jump:


Users browsing this thread: 1 Guest(s)