Hex() PB Help is incomplete
Hex() PB Help is incomplete
the help file does not explain the usage well or I am missing something, when you type Hex(variable the hint at the bottom of the IDE shows Hex(Number [,Type])
I tried w, word, l, long for the type but it's ignored however by trial I found that if I use 0 for byte, 1 for word, 2 for long and 3 for quad it works as expected.
are the some constants somewhere that define the types?
I tried w, word, l, long for the type but it's ignored however by trial I found that if I use 0 for byte, 1 for word, 2 for long and 3 for quad it works as expected.
are the some constants somewhere that define the types?
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
There is no 3
#PB_Integer is 2 on x86 and 4 on x64
#PB_Integer is 2 on x86 and 4 on x64
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Not quite...PB wrote:@netmaestro: Come on now, you know better than that!
The flags are just doubling in value as they go (0, 1, 2, 4).
Code: Select all
#PB_Byte = 0
#PB_Word = 1
#PB_Long = 2
#PB_Float = 3
#PB_Quad = 4
#PB_String = 5
#PB_Double = 6
#PB_Character = 7
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
#PB_Integer = #PB_Quad
CompilerElse
#PB_Integer = #PB_Long
CompilerEndIfquidquid Latine dictum sit altum videtur
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
What is exactly #PB_String? when should I use it ?
[EDIT]
I assume that this constant is not provided for the Hex () ?
What constants are used for the Hex() ? I ask it to update the French doc
Code: Select all
Debug Hex(12,#PB_String)I assume that this constant is not provided for the Hex () ?
What constants are used for the Hex() ? I ask it to update the French doc
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
@Comtois
only #PB_Byte, #PB_Word, #PB_Long, #PB_Quad and #PB_Integer make sense to use with Hex()
the other constants are implemented to provide type describing constants for ANY function that would need it...
@freak
as there is a flag to determine the length for the returned string now,
it would be nice if it would also contain leading zeros.
when you want a hexadezimal string, you (almost) always want leading zeros.
only #PB_Byte, #PB_Word, #PB_Long, #PB_Quad and #PB_Integer make sense to use with Hex()
the other constants are implemented to provide type describing constants for ANY function that would need it...
@freak
as there is a flag to determine the length for the returned string now,
it would be nice if it would also contain leading zeros.
when you want a hexadezimal string, you (almost) always want leading zeros.
oh... and have a nice day.
thanks guys, I was looking for constants in the constant viewer but looking for #WORD etc.
[edit] why not include float and double for the Hex function?
presently you would have to do something like this
[/edit]
[edit] why not include float and double for the Hex function?
presently you would have to do something like this
Code: Select all
Structure MyDbl
StructureUnion
d.d
q.q
EndStructureUnion
EndStructure
n.MyDbl
n\d=1.234
Debug Hex(n\q,4)
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
I don't think it woild make ANY sense to display a floating point number in hexadecimal or binary...
I mean, hey, who the heck could read something like 3 BC 4F.5F 3C ?
(what would be around 244 815.372 009 277 343 75 if I got it right)
Hexadecimal is a useful notation because it has an integer relation of digits to bytes.
two digits per byte. thats it.
for fractions, humans are used to their native number's base, ten, the decimal notation.
... and yes, your "result" could be called "wrong", because you just show the bitwise translation of floating point storage, but not a hexadecimal fraction.
I mean, hey, who the heck could read something like 3 BC 4F.5F 3C ?
(what would be around 244 815.372 009 277 343 75 if I got it right)
Hexadecimal is a useful notation because it has an integer relation of digits to bytes.
two digits per byte. thats it.
for fractions, humans are used to their native number's base, ten, the decimal notation.
... and yes, your "result" could be called "wrong", because you just show the bitwise translation of floating point storage, but not a hexadecimal fraction.
oh... and have a nice day.
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact: