Go Down

Topic: faster printing of floats by divmod10() and others (Read 23 times) previous topic - next topic

darryl

#65
Sep 01, 2013, 01:38 pm Last Edit: Sep 09, 2013, 11:51 pm by darryl Reason: 1
back with my changes to print.cpp to account for the actual ( real accurate digits the number can hold ) when in SCI / ENG mode, this should apply to the rounding you are seeing here ?

ie. if the data doesn't hold a value worth rounding then dont do it maybe ?
--
 Darryl

pito

#66
Sep 01, 2013, 02:54 pm Last Edit: Sep 01, 2013, 03:22 pm by pito Reason: 1
Quote
That's ok but one moment the 5th digit is O(E-1) the other time it is O(E-2) or O(E-3)

I did not study the code, but I would expect you go from raw mantissa (significand - there are all the digits available ), for n-digits-precision take first n+1, round, go back to n and so on. You do not need exponent to know for messing with digits, I think..
Code: [Select]
For 4 digits precision:
m:  999999   exp: x
take first 4+1 digits and round
m:  99999+5   exp:x
m: 100004 and  if 1st digit went from 9->1 x=x+1
take first 4 digits
m: 1000 exp: x+1
do conversion to ENG/SI

robtillaart

new BETA version of my print.cpp/.h

+ rounding SCI/ENG/SI

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

robtillaart


Quote
That's ok but one moment the 5th digit is O(E-1) the other time it is O(E-2) or O(E-3)

I did not study the code, but I would expect you go from raw mantissa (significand - there are all the digits available ), for n-digits-precision take first n+1, round, go back to n and so on. You do not need exponent to know for messing with digits, I think..
Code: [Select]
For 4 digits precision:
m:  999999   exp: x
take first 4+1 digits and round
m:  99999+5   exp:x
m: 100004 and  if 1st digit went from 9->1 x=x+1
take first 4 digits
m: 1000 exp: x+1
do conversion to ENG/SI


- The raw mantissa is not a decimal value. It is binary, and the exponent is binary too (google IEEE754 wikipedia)
- To change the first n digits of a float into an integer value I need to multiply the float by some number. To find that number is (almost) equivalent to finding the exponent.

Quote
I did not study the code,

please do ...
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Constantin

Hi Rob,

Thanks for your updates to print, I have been using bignumbers as a substitute.

Just wondering, is your fix going to become part of the default IDE?

Also, how hard would it be to implement longer 'standard' numbers in the  IDE? I am interested in int128, for example. For that matter, it would be great if double was in fact a double float...

Go Up