Shop OBEX P1 Docs P2 Docs Learn Events
convert long to byte — Parallax Forums

convert long to byte

JohnnyfumiJohnnyfumi Posts: 14
edited 2008-06-30 12:35 in Propeller 1
Hy, is there anybody that know how to convert long to an array of byte? i'm using a flotingpoint long (as 3.4) and i want to write this on a secure digital (i use fsrw.spin), so i havo to convert this long in a byte (array of 4 byte), but i don't know how to do this.

thanks

Johnny

Comments

  • RaymanRayman Posts: 14,233
    edited 2008-06-30 12:12
    I don't see the need to convert to byte... Just use FSRW's pwrite command, give address of variable and tell it to write 4 bytes.

    But, if you insist, you can use the byte[noparse]/noparse syntax: pputc(longvar.byte[noparse][[/noparse]0])
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-06-30 12:35
    Don't forget, longs in the Propeller are stored in reverse order (little-endian). LSB first and MSB last.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.