Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Math library for Free Basic
#51
Of course, all contributions are welcome Tongue

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...
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#52
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).
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#53
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.
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#54
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.
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#55
The library has been updated:

* Added rounding functions (contributed by R. Keeling)
* Added Lambert function
* New demo program: function plotter
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#56
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.
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#57
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
Reply
#58
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.
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)