Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QB664PE v3.10.0 is now live for X-Mas!!
#31
No, but...
But I...
That's not...

Curses, they're onto me!
Reply
#32
(12-23-2023, 12:52 AM)SMcNeill Wrote: Ha!  You can *say* that, but we all know the real reason you're here!  It's the same as everyone else's -- it's 'cause Steve is Awesome-and-Sexy, and the whole world has a crush on him and wants to be where he's at!   Since I, the Awesome Steve, is here, logic only dictates that THAT is why you -- and everyone else -- wants to be here as well!!  

Big Grin
there's a grain of truth in your braggadocious statement Wink 
a successful community and project ( QB64pe ) need an active leader
Reply
#33
Code: (Select All)
Const CONST_BLUE = &HFF0000FF
var_BLUE& = &HFF0000FF

Screen _NewImage(500, 300, 32)

Color CONST_BLUE
Print "CONST_BLUE = 0 (black) so this line is not seen!"

Color var_BLUE&
Print "This is Blue"
Something seems wrong with Const and hex-notation
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply
#34
[Image: image.png]

That's.... just a weee off.
Reply
#35
(12-27-2023, 01:19 PM)SMcNeill Wrote: [Image: image.png]

That's.... just a weee off.

It's implicit sign extension. If the highest bit in the hex variable is set, one should always EXPLICITLY tell the datatype by using type suffixes. The following works...

Code: (Select All)
CONST const_blue = &HFF0000FF&&
PRINT const_blue, HEX$(const_blue)

and this too...
Code: (Select All)
CONST const_blue = &HFF0000FF~&
PRINT const_blue, HEX$(const_blue)

by the way, 32-bit colors should be unsigned values anyways, it's explicitly mentiond in the wiki in several places regarding image/color usage. Wish people would just once look there befor complaining, its rather sucking to maintain the wiki and knowing nobody use it when needed.
Reply
#36
In this case, it doesn't appear to be CONST itself that's off, but something more internal, which we're just seeing via CONST here.

For hex values, CONST doesn't try to interpret the best value for us when calculating the number; it just assigns it to an _UNSIGNED _INTEGER64 -- which should hold the largest hex values that we push it, with no problems.

The problem is, at that internal step, the value is now getting corrupted:

Code: (Select All)
t~&& = &HFFFF
Print Hex$(t~&&)

Quote:FFFFFFFFFFFFFFFF

Those aren't the same two values at all!
Reply
#37
(12-27-2023, 01:35 PM)RhoSigma Wrote: It's implicit sign extension. If the highest bit in the hex variable is set, one should always EXPLICITLY tell the datatype by using type suffixes. The following works...

Code: (Select All)
CONST const_blue = &HFF0000FF&&
PRINT const_blue, HEX$(const_blue)

and this too...
Code: (Select All)
CONST const_blue = &HFF0000FF~&
PRINT const_blue, HEX$(const_blue)

by the way, 32-bit colors should be unsigned values anyways, it's explicitly mentiond in the wiki in several places regarding image/color usage. Wish people would just once look there befor complaining, its rather sucking to maintain the wiki and knowing nobody use it when needed.
You might be totally right, but it breaks 10 years of QB64 code that always accepted
Code: (Select All)
Const BLUE = &hFF0000FF
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply
#38
(12-27-2023, 04:32 PM)mdijkens Wrote:
(12-27-2023, 01:35 PM)RhoSigma Wrote: It's implicit sign extension. If the highest bit in the hex variable is set, one should always EXPLICITLY tell the datatype by using type suffixes. The following works...

Code: (Select All)
CONST const_blue = &HFF0000FF&&
PRINT const_blue, HEX$(const_blue)

and this too...
Code: (Select All)
CONST const_blue = &HFF0000FF~&
PRINT const_blue, HEX$(const_blue)

by the way, 32-bit colors should be unsigned values anyways, it's explicitly mentiond in the wiki in several places regarding image/color usage. Wish people would just once look there befor complaining, its rather sucking to maintain the wiki and knowing nobody use it when needed.
You might be totally right, but it breaks 10 years of QB64 code that always accepted
Code: (Select All)
Const BLUE = &hFF0000FF

Oh, there's no problem accepting the Const BLUE = &HFF0000FF, it always did and will continue to do so, but it can't know what's in the programmers mind. Just by calling your const "BLUE", const can't know it shall be a color value which needs to be treated as unsigned number, for const it's still just some number, only the programmer knows what it is intended for and should code it that way.

All that brings me once again back to RhoSigma's zero'th law of coding:
If you want/need a certain state or behavior, than define it in your code as clear as possible using all capabilities available in the used programming language. Never depend or even worse assume any default behavior.

Unfortunatly many coders do not, cause it offten includes a lot more keypresses, such as using type suffixes, declaring variables, using long unambigious variable names and so on.
Reply
#39
There's a glitch in there somewhere.  It's not just an issue of type casting; it's tossing out incorrect values as it's evaluating incorrect input from the get go.  Now WHY it's doing that is still a mystery at the moment, but we're digging into it.
Reply
#40
Hope this helps, directly assigned hex values under 16 bits are fine... but go over and it blows up. But the math still functions correctly when you go over 16 bits.
Code: (Select All)
Screen _NewImage(100, 35, 0)
Print "unsingned integer"
Dim Q As _Unsigned Integer
Q = &H7FFF
Print Hex$(Q), _Bin$(Q), Q
Q = &H8FFF
Print Hex$(Q), _Bin$(Q), Q
Print "integer"
Dim Q2 As Integer
Q2 = &H7FFF
Print Hex$(Q2), _Bin$(Q2), Q2
Q2 = &H8FFF
Print Hex$(Q2), _Bin$(Q2), Q2
Q2 = &H8000
Print Hex$(Q2), _Bin$(Q2), Q2



Print "long"
Dim Q3 As Long
Q3 = &H7FFF
Print Hex$(Q3), _Bin$(Q3), Q3
Q3 = &H8FFF
Print Hex$(Q3), _Bin$(Q3), Q3
Q3 = &H8000
Print Hex$(Q3), _Bin$(Q3), Q3

Print "unsigned long"
Dim Q4 As _Unsigned Long
Q4 = &H7FFF
Print Hex$(Q4), _Bin$(Q4), Q4
Q4 = &H8FFF
Print Hex$(Q4), _Bin$(Q4), Q4
Q4 = &H8000
Print Hex$(Q4), _Bin$(Q4), Q4

Print "integer 64"
Dim Q5 As _Integer64
Q5 = &H7FFF
Print Hex$(Q5), _Bin$(Q5), Q5
Q5 = &H8FFF
Print Hex$(Q5), _Bin$(Q5), Q5
Q5 = &H8000
Print Hex$(Q5), _Bin$(Q5), Q5

Print "unsigned integer 64"
Dim Q6 As _Unsigned _Integer64
Q6 = &H7FFF
Print Hex$(Q6), _Bin$(Q6), Q6
Q6 = &H8FFF
Print Hex$(Q6), _Bin$(Q6), Q6
Q6 = &H8000
Print Hex$(Q6), _Bin$(Q6), Q6

Print "unsigned integer 64"
Q6 = &H7FFF
Print Hex$(Q6), _Bin$(Q6), Q6
Print Hex$(Q6 + 1), _Bin$(Q6 + 1), Q6 + 1
Print Hex$(Q6 + 2), _Bin$(Q6 + 2), Q6 + 2
Print "unsigned integer 64 but value is assigned as an integer"
Q6 = 32767
Print Hex$(Q6), _Bin$(Q6), Q6
Print Hex$(Q6 + 1), _Bin$(Q6 + 1), Q6 + 1
Print Hex$(Q6 + 2), _Bin$(Q6 + 2), Q6 + 2
Reply




Users browsing this thread: 1 Guest(s)