BST floating point issue?
mhm21
Posts: 14
I recently switched to using BST as I needed the unused code removal function. This is possibly be inane, but I ran into an issue using a floating point constant. In the prop tool, I can make an inline definition or declare a constant such as
I won't say how many hours I spent tracking this down. It was buried deep in an ongoing project and led to an eventual (hours) divergence issue. Also, this value was a cut/paste from Matlab and I do not need anywhere close to the precision I have listed. However, it is an annoying behavior to the uninitiated.
Aside from this oddity, are there any other quirks to expect when using BST? I searched through the forums but did not come up with anything major.
CON A = 1.23456789123e-6 PUB A := 1.23456789123e-6When I compile using BST, and attempt to print the number using floattostring, I get 1.23457e-9. I realize that I am exceeding the capacity of a floating point single in my declaration, but is this a known issue?
I won't say how many hours I spent tracking this down. It was buried deep in an ongoing project and led to an eventual (hours) divergence issue. Also, this value was a cut/paste from Matlab and I do not need anywhere close to the precision I have listed. However, it is an annoying behavior to the uninitiated.
Aside from this oddity, are there any other quirks to expect when using BST? I searched through the forums but did not come up with anything major.
Comments
I wasn't aware of that glitch in BST. I generally use the Propeller Tool.
Some issues when dealing with values close to pi were discussed here:
http://forums.parallax.com/showthread.php/125498-Any-ways-to-speed-up-Float32?p=1298631&viewfull=1#post1298631
Make sure you're using the latest version of F32. As discussed in the above thread, an earlier version had a bug in the ATAN2 method.
If you're running low on RAM, there are a few tricks which can be done with loading PASM images from SD cards or EEPROM. I modified F32 a bit to allow it to be loaded from EEPROM.
http://forums.parallax.com/showthread.php/160005-F32-as-a-quot-Cogject-quot-(Sort-Of)
The same modified code could also be loaded to/from a SD card.
Most objects which have a PASM section can be separated into Spin and PASM parts and the PASM sections can be stored in external memory. The program will need a buffer (about 2K or at least as long as the largest PASM block) to temporarily hold the PASM images (one at a time) but this 2K buffer can then be reused for other purposes such as an UART buffer.
Th input numbers seems to be:
A := 1.23456789123e-6
But the printed output is given as:
1.23457e-9
That's out by a factor of one thousand! Never mind the loss of least significant digits. Assuming no typos in the first post.
Duane,
I have been following your eeprom tricks for some time. I have instituted a couple of them for the F-32 objects etc. Works like a champ. 32k means I have to replace brute force with being clever. Unfortunately, clever is very rarely my thing!