What i want for xmas is QB64-PE v3.15 - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: Announcements (https://qb64phoenix.com/forum/forumdisplay.php?fid=18) +--- Thread: What i want for xmas is QB64-PE v3.15 (/showthread.php?tid=3276) Pages:
1
2
|
RE: What i want for xmas is QB64-PE v3.15 - SMcNeill - 12-14-2024 (12-14-2024, 01:39 AM)Pete Wrote: What is _cast good for, broken code? _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. RE: What i want for xmas is QB64-PE v3.15 - Petr - 12-14-2024 Amazing! I went through the @RhoSigma link and I'm excited about it. Saturation! Brightness! Wave! Great! RE: What i want for xmas is QB64-PE v3.15 - RhoSigma - 12-14-2024 (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! 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. |