Shop OBEX P1 Docs P2 Docs Learn Events
EEprom help negative and decimal numbers? — Parallax Forums

EEprom help negative and decimal numbers?

grasshoppergrasshopper Posts: 438
edited 2008-07-09 16:19 in Propeller 1
Has any one put a negative number in EEprom using the Bs2 object? Along with negative numbers I wish to use decimals too.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-09 16:19
    I haven't actually used the BS2 object, but I'm familiar with the code. As long as you read/write long values (4 bytes), negative numbers should work fine. Shorter values (2 bytes or 1 byte) are always treated as positive unless you use the sign extension operators (~ and ~~ ... see the Manual).

    The Propeller doesn't normally do decimals even though the compiler can do floating point constant expressions. All arithmetic is integer. If you use the floating point library from the Object Exchange, then you can use floating point arithmetic on variables using the methods in the library. These are just 32 bit values. As long as you read/write long values (4 bytes), the floating point values in the longs can be written and read back from EEPROM.
Sign In or Register to comment.