ASCII to Integer ?

budman231

New Member
After using BIN2ASCII, is there any way to convert the ASCII chars (in D0-D4) to numeric to perform math functions on them ?

BinToASCII Humidity,D4,D3,D2,D1,D0

This is TRUE
If D3="2"

This is NOT TRUE
If D3=2 then

Bud
 

Technical

Technical Support
Staff member
test on a number 48 larger than the target value, as ascii is value + 48

if D3 = 50 then
 

eclectic

Moderator
Until the experts arrive :- ),
try this little program in the simulator:

Symbol D3 = b0
D3 = "2"


b11 = D3 - 48


Sertxd (#D3, " ", #b11)

e

Addit They've arrived. :- )
 

budman231

New Member
Thanks for the reply..

Output = 50 2

So if I subtract 48 from the ASCII value I will get the Numeric value ?

NEAT'O Thanks a lot !

Bud

Until the experts arrive :- ),
try this little program in the simulator:

Symbol D3 = b0
D3 = "2"


b11 = D3 - 48


Sertxd (#D3, " ", #b11)

e

Addit They've arrived. :- )
 

BESQUEUT

Senior Member
Thanks for the reply..

Output = 50 2

So if I subtract 48 from the ASCII value I will get the Numeric value ?

NEAT'O Thanks a lot !

Bud
You can also substract "0" wich is the 48nd ASCII character:
Code:
[color=Blue]Symbol [/color][color=Black]D3 [/color][color=DarkCyan]= [/color][color=Purple]b0[/color]
[color=Black]D3 [/color][color=DarkCyan]= [/color][color=Red]"2"[/color]

[color=Purple]b11 [/color][color=DarkCyan]= [/color][color=Black]D3 [/color][color=DarkCyan]- [/color][color=Red]"0"[/color]

[color=Blue]Sertxd ([/color][color=Black]#D3, [/color][color=Red]" "[/color][color=Black], #[/color][color=Purple]b11[/color][color=Blue])[/color]
 

hippy

Ex-Staff (retired)
So if I subtract 48 from the ASCII value I will get the Numeric value ?
Correct. And if you find you can't remember 48 is the ASCII value for the zero character, then you can just subtract "0" ( that's a zero, not an 'oh' )...

D4 = D4 - "0"
D3 = D3 - "0"
etc
 
Top