Page 1 of 1

How to get the mantissa without float??

Posted: Mon Sep 22, 2014 1:44 am
by lightbug
Hi, I want to get the mantissa of a number.

The problem is this:

Example --> 50/1000 = 0.050 ---> with DIV ( / ) gives me "0" , and with MOD ( % ) gives me "50" ...
so the final number displayed in the LCD is 0.50 !!

I'm using float numbers and if statements , so I can compare the float and add zeros (ASCII) but float numbers are using most of the rom and ram

what can i do to get the mantissa "with the zeros"?

thanks! :D

Re: How to get the mantissa without float??

Posted: Mon Sep 22, 2014 11:38 am
by Benj
Hello,

I posted a v6 file here which does lots of number crunching using integer maths and then manipulates the number to print out on the LCD as if it were a floating point value.

http://www.matrixtsl.com/mmforums/viewt ... der#p61763

The Macro in question is the PrintNumWithDP which adds in a decimal point at the given position in the input number.

e.g. NumDP = 2, Number = 123, LCD output string = 1.23

You will need Flowcode 6 installed to open and view the example file but you should be able to re-create the macro in v5 without any problems.