Convert small 64bit signed integer into a high and low byte ?


Author Message
DigitalDreams
Regular Member

Joined: 03/05/2025
Location: United Kingdom
Posts: 65
Posted: 05:18pm 14 Apr 2026      

My next challenge is to save signed integers to an I2c memory chip. They will only range from say -300 to +900 so will be saving as two bytes (high and low) as if a 16bit integer, not the incoming MMBasic 64bit.

For example -

Dim as integer Xmin,Dhi,Dlo
Xmin=-298
...
...
I2c write &h50,0,4,1,0,Dhi,Dlo

I'm already writing small positive MMBasic 64bit integers as single bytes as MMBasic converts/truncates to 8bit in the i2c command itself.

Wondering what the fastest and most efficient way would be to do this ?