Help and questions on programming the codebug
-
mikerr
- Posts: 86
- Joined: Fri Jul 31, 2015 10:37 am
-
Contact:
Post
by mikerr » Mon Sep 28, 2015 9:22 am
pigraham wrote:
get string sprite operates like a stream to convert numeric variables to strings. You can "print" a variable by scrolling it across the LED array.
Unfortunately I just found that numeric decimals only work on the emulator, not on a real bug:
3.141592 => "3.141592" on emulator, but truncated to just "3" on a real codebug:
http://www.codebug.org.uk/explore/codeb ... culate-pi/
Not sure which behavior is correct / by design ?
-
mikerr
- Posts: 86
- Joined: Fri Jul 31, 2015 10:37 am
-
Contact:
Post
by mikerr » Mon Sep 28, 2015 9:44 am
A bit more investigation shows the real->string gives a whopping 16 decimal places in the emulator:
http://www.codebug.org.uk/explore/codeb ... ring-test/
Not sure if that's the full maths precision or just string conversion (4 figures would be better for a real->string conversion)
It's 0 decimal places on a codebug (converts to integer).
-
pigraham
- Posts: 67
- Joined: Sat Aug 15, 2015 1:41 pm
Post
by pigraham » Mon Sep 28, 2015 1:57 pm
Does CodeBug handle reals at all? Set variable to a decimal and it shows the integer equivalent.
I assumed it is integer only. Floating point would be overkill for such a simple device.
How are you defining your real values?
Seems to be integer only on the bug.
http://www.codebug.org.uk/explore/codeb ... eger_only/
-
pigraham
- Posts: 67
- Joined: Sat Aug 15, 2015 1:41 pm
Post
by pigraham » Mon Sep 28, 2015 5:16 pm
I see the same, on the bug. The emulator doesn't overflow.
Interestingly the scrolled text outputs :
32767
-
-32767
-32766
...
I.e. an extra '-' on it's own for what might have been -32768 (0x8000)