Hex() PB Help is incomplete

Everything else that doesn't fall into one of the other PB categories.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

@Kaeru, Maybe you just want the hex representation of the float data for something...

Code: Select all

Fl.f = 1.23456
Lng.l = 0
PokeL(@Lng,PeekL(@Fl))
Debug Hex(Lng)
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

well sure, but this is not the functionality of a HEX() function.

a HEX() function returns the hexadecimal notation of a given decimal number. period.

any showing the bitmask of a floating-point storage has N.O.T.H.I.N.G. to do with this functionallity,
and thus SHOULD NOT be implemented into this function call.


b.t.w. this is also a problem that could be solved with a container:

Code: Select all

Structure FloLo
  StructureUnion
    L.l
    F.f
  EndStructureUnion
EndStructure

Define container.FloLo

container\F = 1.23456 

Debug container\L
Debug Hex( container\L )

Debug  Bin( container\L )
plain to see here:
the container holds the bit represents of the number put in, in this case a float.
debug it as long to get the decimal integer represent, use HEX() on it to display the Hexadecimal integer represent.

only the binary display shows anything of use, beause you can (potentially) identify mantissa and exponent.
in both other notations the border of them falls into a single digit, so you cant devide them by looking at the number.
oh... and have a nice day.
Post Reply