Intel Decimal Floating-Point Math Library

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Intel Decimal Floating-Point Math Library

Post by srvaldez »

compiled for win32/64 https://software.intel.com/content/www/ ... brary.html
this decimal math library includes the types decimal32, decimal64 and decimal128
the library includes the elementary transcendental functions like trig and exponential
also included is a rudimentary overload bi to make it easy to use, download from https://drive.google.com/file/d/19b1J7x ... sp=sharing
Last edited by srvaldez on Feb 26, 2021 12:06, edited 4 times in total.
hhr
Posts: 206
Joined: Nov 29, 2019 10:41

Re: Intel Decimal Floating-Point Math Library

Post by hhr »

Something seems to be wrong...

Code: Select all

#include "libbid.bi"

Using quad_dec

Dim As Decimal128 x

Print 4*Atn(1)
Print " 3.141592653589793238462643383279502884"

x=4*Atn(1)
Print x

x=2*Asin(1)
Print x

Print

Print " 1,4142135623730950488016887242097"

x=Sqr(2)
Print x

Sleep
hhr
Posts: 206
Joined: Nov 29, 2019 10:41

Re: Intel Decimal Floating-Point Math Library

Post by hhr »

My mistake, arguments must be of type Decimal128. Thank you.

Code: Select all

#include "libbid.bi"

Using quad_dec

Dim As Decimal128 x,i

Print 4*Atn(1)
Print 2*Asin(1)
Print 2*Acos(0)
Print Acos(-1)
Print " 3.141592653589793238462643383279502884"

i=1
x=4*Atn(i)
Print x

x=2*Asin(i)
Print x

i=0
x=2*Acos(i)
Print x

Print Acos(Decimal128(-1))

Print

Print Sqr(2)
Print " 1,414213562373095048801688724209698"

i=2
x=Sqr(i)
Print x

Print

Print x*x
Print x^2
Print Exp(2*Log(x))
Print Exp(Log(x)+Log(x))
Sleep
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Intel Decimal Floating-Point Math Library

Post by srvaldez »

I polished up the bi, a bit closer to complete
one thing to keep in mind is that if you assign a double value to a decimal variable the value will most likely on be accurate to double precision
unless the double is an integer that fits in a double or it's an integer or fractional power of 2, for example 0.5 is ok but 0.1 is not but x="0.1" is ok
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Intel Decimal Floating-Point Math Library

Post by srvaldez »

fixed a copy/paste mistake in unary -
<edit> in retropect, instead of the Namespace quad_dec I should have used Namespace BID, in case one doesn't want to Using BID one can use the relatively short prefix BID
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Intel Decimal Floating-Point Math Library

Post by srvaldez »

updated the bi file for better string conversion namely trim off unnecessary 0's
same link in first post
Post Reply