String manipulation question
I am trying to format the printout of a number to include a fixed Decimal point.· I am using integer math and have scaled the number so it is 100 X the actual number and thus the two least significant digits should be behind a decimal place.· Example: The value in memory is 1268. I would like to display this as 12.68.· I have looked through the object exchange but have not found any basic string manipulation functions that would let me· insert the decimal point into the string. I am sure others have done this many times. I realize that it would not be too difficult to write the code to do the buffer manipulations but I would like to hear from people before I code a basic building block type of routine. Any suggestions on good approaches would be greatly appreciated.
·
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Searider
·
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Searider

Comments
PUB dec(value) | i '' Print a decimal number if value < 0 -value tx("-") i := 1_000_000_000 repeat 10 if value => i tx(value / i + "0") value //= i result~~ elseif result or i == 1 tx("0") i /= 10Modified to have a fixed decimal point:
PUB decFixed(value,places) | i, power '' Print a decimal number if value < 0 -value tx("-") i := 1_000_000_000 repeat power from 10 to 1 ' Keep track of power of 10 if power == places ' If equal to # places wanted tx(".") ' then put out a decimal point result~~ ' and force zeros to be output if value => i tx(value / i + "0") value //= i result~~ elseif result or i == 1 tx("0") i /= 10▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Searider