Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-11

convert floating point to bcd and vice versa

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I need to convert floating point (Single and Double) to an array of bytes (BCD) and vice versa.
Are there any existed implementation for it ?

Thanks,
Ido

Reply by email

Ewald
to ik
ik wrote
Hello, I need to convert floating point (Single and Double) to an array of bytes

PByte(@YourVariable)[0]
through
PByte(@YourVariable)[SizeOf(YourVariable)-1] ?

Or, if you have an array of SizeOf(YourVariable) bytes, you could do something like this:
Move(YourVariable, YourArray[0], SizeOf(YourVariable))

(note that you might want to take endianess into account, but I don't know if this applies to floats as it does to integers)

Ewald Events don't necessarily happen in chronological order; yet somehow they do persist to happen. Sometime.

Reply by email

ik
to Ewald
Ewald wrote 15 lines
On 11/01/2012 12:22 PM, ik wrote: > Hello, > > I need to convert floating point (Single and Double) to an array of > bytes PByte(@YourVariable)[0] through PByte(@YourVariable)[SizeOf(YourVariable)-1] ? Or, if you have an array of SizeOf(YourVariable) bytes, you could do something like this: Move(YourVariable, YourArray[0], SizeOf(YourVariable)) (note that you might want to take endianess into account, but I don't know if this applies to floats as it does to integers)

Thanks

Show quoted text 9 lines
-- Ewald Events don't necessarily happen in chronological order; yet somehow they do persist to happen. Sometime. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email