float32-->float16?

Discussion in 'OT Technology' started by konrad109, Mar 17, 2008.

  1. konrad109

    konrad109 New Member

    Joined:
    Jan 6, 2006
    Messages:
    4,153
    Likes Received:
    0
    Location:
    Chicago, IL
    Hi, first time in this subforum.

    Does anyone know of a way to convert float32 to float16 if I only have a 16 bit microcontroller to work with? I have 3 16 bit register. Is this too much to ask of this microcontroller (the 68hc11)?
     
    Last edited: Mar 17, 2008
  2. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    Can you just read the first word of the float?
     
  3. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    how many bits does that leave in the mantissa?
     
  4. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Load the 32-bit float into two of the 16-bit registers, then disregard the second register.

    By the way, 16-bit floats can't hold very large numbers, so if your application uses very large numbers, you're SOL unless you buy a better microcontroller.
     
  5. Deevan

    Deevan Active Member

    Joined:
    Jul 12, 2005
    Messages:
    11,719
    Likes Received:
    0
    Location:
    Orlando, FL USA Posts: 4
    This is what I came in here to say.
     
  6. CodeX

    CodeX Guest

    can't you just assign the 32 bit value to a 16 bit register, dropping the most significant byte? If it loads the top byte first and drops the low byte just shift it up first
     
  7. konrad109

    konrad109 New Member

    Joined:
    Jan 6, 2006
    Messages:
    4,153
    Likes Received:
    0
    Location:
    Chicago, IL
    Yes, I have a 68HC11 and I need to hook up a digital compass and gps to it, which sends heading in float32.

    Thats fine. I only need 0-359.9.

    Thanks guys.
     

Share This Page