04-11-2019, 10:10 AM

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:

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

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

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