Hey guys, I'm not a math guy so this one is a bit beyond me. How do I convert a Hexidecimal number to an integer. I see there's a command to do the opposite but I have a the hex code, I just need the number it represents.
Hex numbers
Blitz3D Forums/Blitz3D Programming/Hex numbers A hex number is just a number in base-16. Blitz can do the conversion to base-10 for you. e.g.:
...or are you talking about converting from a string representation of a hex number to an integer? I'm not sure if there's a Blitz function for converting a hex number as a string to a decimal integer. But you probably don't need that since you say you already have the hex number.
Print $ff ; 255
...or are you talking about converting from a string representation of a hex number to an integer? I'm not sure if there's a Blitz function for converting a hex number as a string to a decimal integer. But you probably don't need that since you say you already have the hex number.
with win calculater, you can put it in scientific mode, switch to hex mode, punch in your code, and switch back to decimal. voila. the number is converted.
Yep, looks like the number is in a string. Wonder how I can get the blitz code to convert. I'm pulling a list of hex numbers in a text file that have been generated by another program.
$1=1
$2=2
$3=3
$4=4
$5=5
$6=6
$7=7
$8=8
$9=9
$a=10
$b=11
$c=12
$d=13
$e=14
$f=15
$0b = 11 b-coz ($00=0x16)+($b=11) = ( 0+11) = 11
$13 = 19 b-coz ($10=1x16)+($3=03) = ( 16+03) = 19
$44 = 68 b-coz ($40=4x16)+($4=04) = ( 64+04) = 68
$a3 = 163 b-coz ($a0=10x16)+($3=03) = (160+03) = 163
$ff = 255 b-coz ($f0=16x16)+($f=15) = (240+15) = 255
$6e4a = 28234 b-coz ($6000=6x4096)+($e000=14x256)+($40=4x16))+($a=10) = (24576+3584+64+10) = 28234
OK ?
$2=2
$3=3
$4=4
$5=5
$6=6
$7=7
$8=8
$9=9
$a=10
$b=11
$c=12
$d=13
$e=14
$f=15
$0b = 11 b-coz ($00=0x16)+($b=11) = ( 0+11) = 11
$13 = 19 b-coz ($10=1x16)+($3=03) = ( 16+03) = 19
$44 = 68 b-coz ($40=4x16)+($4=04) = ( 64+04) = 68
$a3 = 163 b-coz ($a0=10x16)+($3=03) = (160+03) = 163
$ff = 255 b-coz ($f0=16x16)+($f=15) = (240+15) = 255
$6e4a = 28234 b-coz ($6000=6x4096)+($e000=14x256)+($40=4x16))+($a=10) = (24576+3584+64+10) = 28234
OK ?
yan - again I am too late! ;) yours is very efficient btw.
I'm extremely lazy and try to type as little as possible ;o)
YAN
YAN