NO

Author Topic: atof  (Read 1200 times)

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 71
    • Bcx Basic to C/C++ Translator
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 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


Offline Grincheux

  • Member
  • *
  • Posts: 83
  • Never be pleased, always improve
    • Arachne
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

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1915
« Last Edit: November 24, 2020, 07:20:15 am by TimoVJL »
May the source be with you

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1789
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 »

Offline Grincheux

  • Member
  • *
  • Posts: 83
  • Never be pleased, always improve
    • Arachne
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

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1915
Re: atof
« Reply #20 on: November 25, 2020, 05:11:02 pm »
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