News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

atof

Started by Grincheux, November 14, 2020, 12:29:58 PM

Previous topic - Next topic

MrBcx

Quote from: Grincheux on November 23, 2020, 06:33:14 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 fpAdd$ ("999.123456789","100")

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

Bcx Basic to C/C++ Translator
https://www.bcxbasiccoders.com

Grincheux

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.

TimoVJL

May the source be with you

frankie

#18
Quote from: Grincheux on November 23, 2020, 06:33:14 PM
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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Grincheux

There are too many numbers after the decimal point!


Thank You Frankie & Timo I will use the library

TimoVJL

QDC library should follow lisence:
https://www.davidhbailey.com/dhbsoftware/LBNL-BSD-License.docx

PS.
David H Bailey accept that QDC project.

May the source be with you