Improve precision of float numbers
04-11-2019, 10:10 AM
Post: #1
 deetee Member Posts: 66 Joined: May 2016
Improve precision of float numbers
Hi all!

I like to build small RPN calculators (ScArY, SCOTT, ARC) with AVR microcontrollers (which are easy to program).

Unfortunately these microcontrollers support float numbers with 4 byte single precision (due IEEE-754) only. That means they support a precision of 6 to 7 decimal digits.

Now I would like to improve this precision to at least 9 decimal digits. The only idea I have is to define a new number format (struct) to separate mantissa and exponent:

Code:
struct real {   long m;   int8_t e; };

But now I have to "reinvent" every mathematical operation like adding two numbers (the following code works, but is far from beeing efficient):

Code:
void realadd(real * res, real a, real b) {   if (a.e >= b.e) {     b.m /= _pow10(a.e-b.e);     res->m = a.m + b.m;     res->e = a.e;   }   else {     a.m /= _pow10(b.e-a.e);     res->m = a.m + b.m;     res->e = b.e;   } }

Looking forward to transzendent functions or complex numbers I feel overstrained.

Do you have any other idea how to raise the precision with less effort?

Thanks for any idea.
deetee
 « Next Oldest | Next Newest »

 Messages In This Thread Improve precision of float numbers - deetee - 04-11-2019 10:10 AM RE: Improve precision of float numbers - Claudio L. - 04-11-2019, 08:25 PM Improve precision of float numbers - deetee - 04-12-2019, 04:23 AM RE: Improve precision of float numbers - Druzyek - 04-12-2019, 12:07 PM RE: Improve precision of float numbers - Claudio L. - 04-12-2019, 06:22 PM Improve precision of float numbers - deetee - 04-13-2019, 09:43 AM RE: Improve precision of float numbers - Claudio L. - 04-16-2019, 02:43 PM RE: Improve precision of float numbers - agarza - 04-13-2019, 02:03 PM RE: Improve precision of float numbers - deetee - 04-14-2019, 05:56 AM RE: Improve precision of float numbers - agarza - 04-17-2019, 11:50 PM RE: Improve precision of float numbers - Chasfield - 04-14-2019, 01:16 PM RE: Improve precision of float numbers - Jonathan Busby - 04-16-2019, 03:59 PM RE: Improve precision of float numbers - deetee - 04-17-2019, 05:07 AM RE: Improve precision of float numbers - Druzyek - 04-17-2019, 02:20 PM RE: Improve precision of float numbers - deetee - 04-19-2019, 08:31 AM

User(s) browsing this thread: 1 Guest(s)