mm to inches
oldhippy
Posts: 36
I am trying to convert mm to inches using a BS2. the BS2 rounds off. Any way to get tenths of an inch out of the BS2?
Comments
If you are doing this in floating point multiply the mm by 10 or 100 and divide by the same amount after the conversion is done.
inch10 = mm ** 25802 ' good up to 65536mm
to hundredths:
inch100 = mm * 10 ** 25802 ' good up to 6553mm
to thousandths
inch1000 = mm * 100 ** 25802 ' good up to 655mm
example
mm = 25
inch1000 = 984 ' meaning 0.984 inch true value 0.984251968505
** 25802 using the PBASIC ** operator.is equivalent to 25802/65536 = ~0.3934
I'm very rusty in PBASIC but this was the output when entering 88 mm.
Here's the program:
Unfortunately the word size variables in PBASIC don't lend themselves to doing math with large numbers. I bet a much better program could be written using the tricks Tracy showed us.