Improve precision of float numbers
|
04-19-2019, 08:31 AM
Post: #15
|
|||
|
|||
RE: Improve precision of float numbers
@Druzyek: Thanks for motivating me.
To save floats in an char array seems to me that it needs much memory (similar to the BigNumber library). To enter an input string and convert it to float is very convenient (I tried this with one of my first calculators - ARC). But finally I switched to interpret every keypress at once and change the X-register immediately. Softfloat, Float64 and Math64 are working properly - but first tries needed too much memory. And on my todo list is calculating with complex numbers, statistics, matrices and at least programming ... I'm sure that it's possible to involve these capabilities with the intrinsic (7 digit precision) float format. But I'll try one last thing (and hope this doesn't consume to much memory): I like the DEC64 format to save mantissa and exponent in one int64_t variable. The advantage is that interchanging numbers with subroutines is very handy. And to convert mantissa and exponent to DEC64 and vice versa can be done very quickly. And the sign of numbers is handled automatically (ie substraction equals addition with negative number ... a-b = a+ (-b) ). The following code demonstrates how this could be done - even if the code is very inefficient and was quickly done. The input and display of those numbers needed approx 3k and involving basic math (+-*/) approx extra 3k. What I still can't estimate is how much flash will be needed to call these functions very often (ie in case of calculating exp(x) with Taylor series). Thanks for every hint and help (and motivation) - I love this forum. Code:
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)