32 bit integers
Tristan T
Posts: 31
Hello,
I was wondering if there is a graceful way to represent 32 bit integers on the basic stamp, specifically the BS2px. I have a navigation sensor that returns 2800 counts per meter, so I quickly run into the (2^16)/2 limit. I would prefer not to simply dump 2 significant figures, because the refresh rate of the sensor is very quick, returning very small values that I sum into my TotalX variable. At given intervals I take the TotalX figure and ** it by a scalar to get a meter representation of the distance traveled.
Suggestions?
Thank you in advance,
Tristan.
I was wondering if there is a graceful way to represent 32 bit integers on the basic stamp, specifically the BS2px. I have a navigation sensor that returns 2800 counts per meter, so I quickly run into the (2^16)/2 limit. I would prefer not to simply dump 2 significant figures, because the refresh rate of the sensor is very quick, returning very small values that I sum into my TotalX variable. At given intervals I take the TotalX figure and ** it by a scalar to get a meter representation of the distance traveled.
Suggestions?
Thank you in advance,
Tristan.
Comments
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
Is there a hardware limitation to the number of bits that can be assigned to a single variable name, or is it just a limitation of PBASIC? I understand that a PIC is only 8 bits, but if PBASIC supports 16bit words, then it would appear that the 16 bit maximum is just a support choice rather than a real limitation. I'm studying mechanical engineering so please forgive my ignorance of microcontrollers.
-Tristan
http://www.emesystems.com/BS2math6.htm
Hopefully it will be easier to find with this thread name for other people looking for 32 bit integer operations.
-Tristan