Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What i want for xmas is QB64-PE v3.15
#11
(12-14-2024, 01:39 AM)Pete Wrote: What is _cast good for, broken code? 

Oh maybe it can be used to program a phishing scheme. A good _cast would help with that.

Okay, okay, fine. Sorry to be the one to _cast dispersions, but like the old saying goes, 

"If you _cast your bread upon the water, you feed a fish for a week."

Pete Big Grin 

- Damn right too much eggnog!

_CAST is good for making certain that your data types match.  For example:

DIM Red AS LONG
Red = _RGB32(255,0,0)

Now, with the above, Red is a LONG value.   Let's set a point that color:

COLOR Red
PSET(0,0)

And let's compare that point to Red:

IF Red = POINT(0,0) THEN PRINT "It's RED!" ELSE PRINT "It's NOT Red.  WHUT??"

And...  Guess what?!

IT'S **NOT** RED!!

The problem here is that Red is SIGNED LONG and POINT returns an UNSIGNED LONG type value to us.  Even though the hex values are the same for both numbers, one is -65535 and the other is 4345789012 (or some such values).

Your SIGNED value doesn't match the UNSIGNED value!!



So how's _CAST fix this?

Make the types match!

IF _CAST(_UNSIGNED LONG, Red) = POINT(0,0)....  <-- this now matches as your unsigned value matches the unsigned value.

IF Red = _CAST(LONG, POINT(0,0)....  <-- this would now match as well, as the signed value matches the signed value.

_CAST is used to convert types for you.  It's that simple.  Smile
Reply
#12
Amazing! I went through the @RhoSigma link and I'm excited about it. Saturation! Brightness! Wave! Great!  Big Grin


Reply
#13
(12-14-2024, 09:44 AM)Petr Wrote: Amazing! I went through the @RhoSigma link and I'm excited about it. Saturation! Brightness! Wave! Great!  Big Grin

Thanks @Petr,
but the honor for _WAVE must go to @a740g, although I probably inspired him to make the command long time ago when talking about the Commodore Amiga sound capabilities.
Reply




Users browsing this thread: 1 Guest(s)