Posts: 60
Threads: 8
Joined: Jan 2005
Of course, all contributions are welcome
I will check your rounding routines and add them to the library.
Feel free to add constants, too. If possible, use the following format:
#DEFINE Pi 3.14159...
Posts: 60
Threads: 8
Joined: Jan 2005
I have set up a Yahoo group for this library. It is located at:
http://groups.yahoo.com/group/fbmathlib/
In addition, the group will serve as a repository for the code snippets which are posted here from time to time and may be of interest for the library users. I have already placed 4 of these snippets in the "Files" section of the group (math parsers, color constants, date functions).
Posts: 72
Threads: 11
Joined: Feb 2005
Quote:I have set up a Yahoo group for this library. It is located at:
http://groups.yahoo.com/group/fbmathlib/
[...]
I think Yahoo group better than forum in any case :wink:
I can receive all message via e-mail and store and find on local disk.
Posts: 60
Threads: 8
Joined: Jan 2005
Quote:For example the floor, ceiling, and round? What follows are limited versions that aren't well tested but should give an idea.
Here is a slightly modified version, with a short demo program:
Code:
' Function Round (x as double, Digit_Count as integer = 0) as double
const MaxRoundPlaces = 16
dim ReturnAnswer as double
ReturnAnswer = 0
If (Digit_Count >= 0) and (Digit_Count < MaxRoundPlaces) then
Dim Dec_Place as double
Dec_Place = 10 ^ Digit_Count
ReturnAnswer = int((abs (x) * Dec_Place) + 0.5)
ReturnAnswer = Sgn(x) * ReturnAnswer / Dec_Place
end if
Round = ReturnAnswer
End Function
Function Ceil (x as double) as integer
Dim ReturnAnswer as integer
ReturnAnswer = int(x)
if ReturnAnswer < x then ReturnAnswer = ReturnAnswer + 1
Ceil = ReturnAnswer
End Function
Function Floor (x as Double) as integer
Dim ReturnAnswer as integer
ReturnAnswer = int(x)
if ReturnAnswer > x then ReturnAnswer = ReturnAnswer - 1
Floor = ReturnAnswer
End Function
' *************************************************************
option explicit
dim as double x, h
dim as integer i
' The h value was chosen because it does not have an exact
' binary expansion, so that it generates some rounding errors
h = 0.1
for i = 0 to 10
x = i * h
? x, tab(25), Round(x, 6), Ceil(x), Floor(x)
next i
sleep
I will add these functions to the library.
Thanks for this useful contribution.
Posts: 60
Threads: 8
Joined: Jan 2005
The library has been updated:
* Added rounding functions (contributed by R. Keeling)
* Added Lambert function
* New demo program: function plotter
Posts: 60
Threads: 8
Joined: Jan 2005
The library has been updated. I have added probability functions, some statistical functions, and random number generators.
This version is for FB 0.13b Windows. Some programs may not work with the DOS and Linux versions.
Posts: 489
Threads: 34
Joined: Jan 2005
add a #inclib "math" to the include .bi file and people won't have to bother with the -l math. :wink:
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Posts: 60
Threads: 8
Joined: Jan 2005
Quote:add a #inclib "math" to the include .bi file and people won't have to bother with the -l math. :wink:
OK. It will be in the next update.