Rui Pires
Rui Pires

Reputation: 1

Convert Variable to decimal XBASE

Have a variable containing a value like '000000017733'. - Need to convert it to '000000177,33' - Then make a sum with other variable. - Then convert it again to a string that will look like (for example) '000000008921'

XBASE

any one can help?

something like: **variables VGCA = 77,33 TOT = '000000017733'

** convert TOT to 177,33

** do the needed operation FINALV = TOT - VCGA

** reconvert FINALV from 100,00 to 000000010000

Upvotes: 0

Views: 166

Answers (1)

stolen_leaves
stolen_leaves

Reputation: 1462

Don't know if you still need this or not, but in python 3 the code would look like this -

vgca = 77.33
tot = '000000017733'
tot_float = float(tot)/100
print(tot_float)
finalv = tot_float - vgca
finalv *= 100
finalv_string = format("%012d"%finalv)
print(finalv_string)

the output is -

177.33
000000010000

Upvotes: 1

Related Questions