bintoascii error

gsergean

New Member
hi,
I'm trying to find out how the bintoascii function works and discovered a weird
thing while running the following lines of code:
Code:
pause 500
serout 2, N2400_4, (254,1)	'Clear Screen
pause 30

main:
	for b1 = 1 to 11 
		bintoascii b1,b2,b3,b4 ‘ convert b1 to ascii
		serout 2, N2400_4, (254, 192, #b1, " -  ", b2, b3, b4)
		debug ‘ debug values for testing
	next b1
goto main
the output gives

1 - 001
2 - 002
3 - 003
4 - 004
5 - 005
6 - 016
7 - 017
8 - 018
9 - 019

10 - 010
11 - 011

Does anyone know why from 6 until 9 the output gives 016 instead of 006

syntax of the bintoascii function:
BINTOASCII variable, hundreds, tens, units
BINTOASCII wordvariable, tenthousands, thousands, hundreds, tens, units
- Variable contains the value (0-255) or wordvariable (0-65535)
- TenThousands receives the ASCII value (“0” to “9”)
- Thousands receives the ASCII value (“0” to “9”)
- Hundreds receives the ASCII value (“0” to “9”)
- Tens receives the ASCII value (“0” to “9”)
- Units receives the ASCII value (“0” to “9”)
 
Last edited:

BeanieBots

Moderator
I would expect 5 to give 48,48 and 53 respectively.
that is, "0","0","5".

EDIT:
Just tried this:-
b1=5
bintoascii b1,b2,b3,b4

and it worked fine in the simulator.
 
Last edited:

gsergean

New Member
Yes you're right 5 is given 48,48,53.

But as from 6 it gives 48,49,54 instead of 48,48,54
7 gives 48,49,55 ==> instead of 48,48,55
8 gives 48,49,56 ==> instead of 48,48,56
9 gives 48,49,57 ==> instead of 48,48,57
10 gives 48,49,48 ==> which is again correct
11 gives 48,49,49 ==> which is again correct
12 gives 48,49,50 ==> which is again correct
13 gives 48,49,51 ==> which is again correct
14 gives 48,49,52 ==> which is again correct
15 gives 48,50,53 ==> instead of 48,49,53
16 gives 48,50,54 ==> instead of 48,49,54
17 gives 48,50,55 ==> instead of 48,49,55
...
Can you also simulate this error?
 

lbenson

Senior Member
I can confirm this in the simulator. In counting up to 100, the numbers ending in 6,7,8,9 are 10 higher than they should be:

Code:
main:
  for b1 = 1 to 100 
    bintoascii b1,b2,b3,b4 ‘ convert b1 to ascii
    sertxd(#b1, " -  ", b2, b3, b4)
  next b1
goto main
1 - 001
2 - 002
3 - 003
4 - 004
5 - 005
6 - 016
7 - 017
8 - 018
9 - 019
10 - 010
11 - 011
12 - 012
13 - 013
14 - 014
15 - 025
16 - 026
17 - 027
18 - 028
19 - 029
20 - 020
 

BeanieBots

Moderator
Concur with results in simulator (Ver 5.2.7) for all breeds.
Not tried on actual PICAXE.

6 to 9 and 15 to 19 set "tens" 1 higher than expected.
 

hippy

Ex-Staff (retired)
That simulator bug has already been noted ( due to the general division bug ) and will be fixed in due course.
 

gsergean

New Member
Okay thanks for clearing this out.
Any idea when a fix for it will come out?

Can you tell me where I can find such information concerning bugs and stuff?
 

BeanieBots

Moderator
Good point gsergean.
A link/sticky of known/reported bugs would be very useful.

There is this http://www.rev-ed.co.uk/software/revision.txt which lists the historic corrections and known issues at time of release.

You can also find firmware.txt in the programming editor folder.
It lists firmware bugs/fixes for each PICAXE.

Also, the relevant forum for reporting bugs.
 

mega

New Member
Concur with results in simulator (Ver 5.2.7) for all breeds.
Not tried on actual PICAXE.

6 to 9 and 15 to 19 set "tens" 1 higher than expected.
Works fine on an 18X, at least the 3 digits I wanted to read from a word is fine.

Cheers.
 
Top