Hello everybody ,
for my project i need to convert values/numbers into ASCII values. My ‘poor mans’ code works, but i would like to avoid that, especially for negative values. The following is a ±50 example, with a incoming qq that is limited to that range. It is as follows:
Summary
if qq==14 then v2=53
if qq==14 then v3=48
if qq>14 then v2=52
if qq==15 then v3=57
if qq==25 then v3=57
if qq==35 then v3=57
if qq==45 then v3=57
if qq==55 then v3=57
if qq==16 then v3=56
if qq==26 then v3=56
if qq==36 then v3=56
if qq==46 then v3=56
if qq==56 then v3=56
if qq==17 then v3=55
if qq==27 then v3=55
if qq==37 then v3=55
if qq==47 then v3=55
if qq==57 then v3=55
if qq==18 then v3=54
if qq==28 then v3=54
if qq==38 then v3=54
if qq==48 then v3=54
if qq==58 then v3=54
if qq==19 then v3=53
if qq==29 then v3=53
if qq==39 then v3=53
if qq==49 then v3=53
if qq==59 then v3=53
if qq==20 then v3=52
if qq==30 then v3=52
if qq==40 then v3=52
if qq==50 then v3=52
if qq==60 then v3=52
if qq==21 then v3=51
if qq==31 then v3=51
if qq==41 then v3=51
if qq==51 then v3=51
if qq==61 then v3=51
if qq==22 then v3=50
if qq==32 then v3=50
if qq==42 then v3=50
if qq==52 then v3=50
if qq==62 then v3=50
if qq==23 then v3=49
if qq==33 then v3=49
if qq==43 then v3=49
if qq==53 then v3=49
if qq==63 then v3=49
if qq==24 then v3=48
if qq==34 then v3=48
if qq==44 then v3=48
if qq==54 then v3=48
if qq>24 then v2=51
if qq>34 then v2=50
if qq>44 then v2=49
if qq>54 then v2=48
// printing - 0 +
if qq<64 then v1=45
if qq==64 then v1=32
if qq>64 then v1=43
if qq==64 then v2=32
if qq==64 then v3=45
if qq==64 then v4=67
else v4=67
if qq==64 then v5=45
else v5=110
if qq==64 then v6=32
else v6=116
if qq>64 then v2=48
if qq>64 then v3=qq-16
if qq>73 then v2=49
if qq>73 then v3=qq-26
if qq>83 then v2=50
if qq>83 then v3=qq-36
if qq>93 then v2=51
if qq>93 then v3=qq-46
if qq>103 then v2=52
if qq>103 then v3=qq-56
if qq>113 then v2=53
if qq>113 then v3=qq-66
v1 should show the prefix ±, v2 only the tens v3 should show only the ones in ASCII.
I have optimized this, to have the value, but i struggle to convert it to ASCII.
This is the current state:
// convert incoming value from hex to dec
qq=qq*16
// 63 neg. & pos. value range
if qq>64 then oo=qq&15
oo=qq/16
oo=oo-64
//convert incoming value back to hex
qq=qq/16
Log "working range %oo%"
How do i put oo into v2 and v3 now? How do i convert v2 and v3 into ASCII numbers (range is 48 to 57 for dec or 30 to 39 for hex for the ASCII numbers). They need a ASCII range limit that defines a wrapper/ loop type of code.
Thanks in advance .