### Author Topic: atof  (Read 1736 times)

#### MrBcx

• Global Moderator
• Member
• Posts: 73
##### Re: atof
« Reply #15 on: November 23, 2020, 08:22:15 pm »

I have read too that a programmer gave numbers in the form of a string.

I have ugly code that I wrote in 1992 that creates 3 functions -- fpAdd, fpSub, and fpMul.
Each takes 2 string arguments.  The BASIC code was written for MSDOS but compiles with Pelles
when converted using my BCX translator.

Examples:

PRINT fpSub\$ ("500.987654321","100")

PRINT fpMul\$ ("999999999999999999.123456789","999999999999999999.123456789")

OUTPUT

1099.123456789
400.987654321
999999999999999998246913578000000000.768328000750190521

Impressively, the fpMul result matches the result obtained here:

https://keisan.casio.com/calculator

#### Grincheux

• Member
• Posts: 141
• Never be pleased, always improve
##### Re: atof
« Reply #16 on: November 23, 2020, 08:28:50 pm »
A good thing and impressive calculator!
I also have found LibBF and GNU MPFR but there is no Windows Version!
It is possible using MinGW but too complicated for me.
-------------------------
Kenavo / Bye

#### TimoVJL

• Global Moderator
• Member
• Posts: 1926
##### Re: atof
« Reply #17 on: November 23, 2020, 08:40:20 pm »
« Last Edit: November 24, 2020, 07:20:15 am by TimoVJL »
May the source be with you

#### frankie

• Global Moderator
• Member
• Posts: 1805
##### Re: atof
« Reply #18 on: November 24, 2020, 12:10:27 am »
What about transforming in two 64 bits numbers.
Than You Frankie for your help.
I would avoid to to reinvent the wheel and write your own math library.
You can use the QD library ported by Timovjl.
I also found another quad precision float library that seems interesting: the HPALIB (High Precision Arithmetic library).
The IEEE 754 2008 binary128 uses 1 bit for sign, 15bits for exponent and 113bits for mantissa. 113bits means 33 significant digits. This means that you can work i.e. with numbers of 16 digits before decimal dot and 16 digits after without precision loss.
« Last Edit: November 24, 2020, 12:25:48 am by frankie »

#### Grincheux

• Member
• Posts: 141
• Never be pleased, always improve
##### Re: atof
« Reply #19 on: November 24, 2020, 06:18:01 pm »
There are too many numbers after the decimal point!

Thank You Frankie & Timo I will use the library
-------------------------
Kenavo / Bye

#### TimoVJL

• Global Moderator
• Member
• Posts: 1926
##### Re: atof
« Reply #20 on: November 25, 2020, 05:11:02 pm »