every now and then the need for a decimal type might come in handy, so I compiled the decQuad part of decNumber and translated the appropriate headers with fbfrog.
I also added dodicat's trig functions.
here's decQuad-Linux
decQuad lib and example
decQuad lib and example
Last edited by srvaldez on Jun 13, 2016 21:03, edited 2 times in total.
Re: decQuad lib and example
Could you provide instructions how to build the static libraries, which you do provide only as binaries?
e.g.:
source: http://download.icu-project.org/files/d ... cu-368.zip
create library with:
gcc -c decQuad.c decContext.c
ar rcs libdecQuad.a decQuad.o decContext.o
e.g.:
source: http://download.icu-project.org/files/d ... cu-368.zip
create library with:
gcc -c decQuad.c decContext.c
ar rcs libdecQuad.a decQuad.o decContext.o
Re: decQuad lib and example
Thanks srvaldez.
I had to re-arrange the folders a bit.
The files in the decnumber folder could not be reached from the example folder (32 bit)
I tested with:
print qdecimal_acos("-1")
And, sure enough, I got a big Pi.
I had to re-arrange the folders a bit.
The files in the decnumber folder could not be reached from the example folder (32 bit)
I tested with:
print qdecimal_acos("-1")
And, sure enough, I got a big Pi.
Re: decQuad lib and example
updated the overload includes and examples.
Re: decQuad lib and example
Hi srvaldez,
Would you happen to have some basic sources that show how to do simple match functions using decQuad?
Would you happen to have some basic sources that show how to do simple match functions using decQuad?
Re: decQuad lib and example
hello jdmcbride
I am not familiar with the match function, is this what you mean?
a rough example might be
I am not familiar with the match function, is this what you mean?
The MATCH function searches for a specified item in a range of cells, and then returns the relative position of that item in the range. For example, if the range A1:A3 contains the values 5, 25, and 38, then the formula =MATCH(25,A1:A3,0) returns the number 2, because 25 is the second item in the range.
a rough example might be
Code: Select all
#include "decNumber\decQuadMathOverload.bi"
function match(byval n as qdecimal, a() as qdecimal) as integer
dim as integer i
For i=lbound(a) to ubound(a)
if a(i)=n then return i
next
return 0
end function
Dim As qdecimal num=25, a(1 to 3)={5, 25, 38}
print match(num, a())
sleep
Re: decQuad lib and example
srvaldez,
Please forgive me. I am advanced in years and between poor eyesight and fat fingers, I can really muck things up.
I meant simple "math" examples.
Actually, I've had a great deal of success with this on my own. Only one I havent ironed out is how to handle the remainder after division.
My project is a base10 to base36 encoder/decoder. However, getting it to handle large, out to 20 or 30 decimal places has been problematic. I'm sure decQuad is the answer, when I figure it out.
it would be wonderfully easy, if FB had greater precision than it has. Maybe a future version will make that possible.
Have a good night sir.
Please forgive me. I am advanced in years and between poor eyesight and fat fingers, I can really muck things up.
I meant simple "math" examples.
Actually, I've had a great deal of success with this on my own. Only one I havent ironed out is how to handle the remainder after division.
My project is a base10 to base36 encoder/decoder. However, getting it to handle large, out to 20 or 30 decimal places has been problematic. I'm sure decQuad is the answer, when I figure it out.
it would be wonderfully easy, if FB had greater precision than it has. Maybe a future version will make that possible.
Have a good night sir.
Re: decQuad lib and example
Since I here... is there an easy way to to separate a big float into a whole number and remainder?
Re: decQuad lib and example
it's close to my bedtime but have a look at the following functions
decQuadReduce, decQuadRemainder, decQuadRemainderNear also look at the pdf file that was included.
decQuadReduce, decQuadRemainder, decQuadRemainderNear also look at the pdf file that was included.
-
- Posts: 8208
- Joined: May 28, 2005 3:28
- Contact:
Re: decQuad lib and example
Tips and Tricks are the wrong section for 'decQuad' it's for source code only
why not using the forum Libraries sextion ?
Joshy
why not using the forum Libraries sextion ?
Joshy
Re: decQuad lib and example
Sure. How to move?
Re: decQuad lib and example
@jdmcbride
from what you wrote, I think that decQuad may not be your best option, if you only need Big Integers then maybe the wrapper for gmp integer type by yetifoot may suit you viewtopic.php?f=7&t=7173
from what you wrote, I think that decQuad may not be your best option, if you only need Big Integers then maybe the wrapper for gmp integer type by yetifoot may suit you viewtopic.php?f=7&t=7173
Re: decQuad lib and example
@jdmcbride
I find no elegant way to get the integer and fractional parts but you can do it the dirty way, you could write a sub or function.
I find no elegant way to get the integer and fractional parts but you can do it the dirty way, you could write a sub or function.
Code: Select all
#include "decNumber\decQuadMathOverload.bi"
dim as qdecimal x="314.1592653"
dim as long fr
dim as string s
s=x.toString
fr=instr(s,".")
print left(s,fr-1),mid(s,fr)
sleep
Re: decQuad lib and example
Hi srvaldez,
Yes, you are correct. I had no luck ether and have resorted to hacking the data as a string. Thank you, so much, for your help.
Jerry
Yes, you are correct. I had no luck ether and have resorted to hacking the data as a string. Thank you, so much, for your help.
Jerry
Who is online
Users browsing this forum: No registered users and 6 guests