Shop OBEX P1 Docs P2 Docs Learn Events
Fixed Point to Digit String — Parallax Forums

Fixed Point to Digit String

RogerInHawaiiRogerInHawaii Posts: 87
edited 2009-08-17 01:57 in Propeller 1
I have a fixed point binary value. It has 16 bits of integer and 16 bits of fractional value. I know how to convert the integer portion to a decimal string, but how do I convert the fractional part to a decimal string?

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2009-08-17 01:57
    Roger, your can look at the current number as a 32-bit value in units of 1/65536. You can use the spin ** operator to scale this so it is in units of 1/10000 instead, then convert it to a straight integer and force four decimal places.

    The scaling constant needed is 10000/65536 * 2^32 or decimal 655360000 (duh) or $27100000.

    Post Edited (localroger) : 8/17/2009 2:03:44 AM GMT
Sign In or Register to comment.