Why can't you store a Long constant?
BlitzMax Forums/BlitzMax Programming/Why can't you store a Long constant?
| ||
I was trying to confirm for myself whether doing Min(a,b), where a and b are both Longs, was actually going to give the correct answer. This is when I realized, that it SEEMS when you do =$7FFFFFFF the value is stored but if you do $F0000000 it stores $FFFFFFFFF0000000. In other words, how are you supposed to define and store a Long number in your code? Local a:Long=$FF00FF00FF00 actually stores $FFFFFFFFFF00FF00 If the sign bit of the Integer (bit 31) is set, it will `extend` the number to a 64-bit signed value, instead of storing the actual 64-bit data you specify as a constant. Const a:Long=$FF00FF00FF00 actually also stores $FFFFFFFFFF00FF00 How are we supposed to put a given 64-bit value into a Long? Even if it is a signed value (ignoring bit 63), it still extends the bit 31 all the way through to 63. ??? Without getting the full number to be stored in a Long, I can't test to see if Min() and Max() are returning the minimum and maximum long values, or integer values. Also why can Hex$() only handle Int values when all you need to do to print a Long is Print Hex$(Long Shr 32)+Hex$(Long & $FFFFFFFF) ??? |
| ||
You can type literals too. Just do Local a:Long=$FF00FF00FF00:Long As stated in the doc. |
| ||
Also why can Hex$() only handle Int values when all you need to do to print a Long is Print Hex$(Long Shr 32)+Hex$(Long & $FFFFFFFF) ??? There is a LongHex command. |
| ||
LongHex? cool. and I will try that :Long thing thanks |
| ||
Hey, it works. LongHex$() prints the whole Long :-) $FF00FF00FF00:Long stores the full Long value :-) Min(a,b) or Max(a,b) gives correct answers for long variables :-) Thanks guys. |