Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Math library for Free Basic
#50
Jean,

Are you going to impliment more elementary functions in the library?

For example the floor, ceiling, and round? What follows are limited versions that aren't well tested but should give an idea.

Code:
Function Round (x as double, Digit_Count as integer = 0) as double
   dim MaxRoundPlaces as integer
   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
   else
      'raise an error
   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

Also, would you be open to expanding the constants list?
Reply


Messages In This Thread
Math library for Free Basic - by jdebord - 01-19-2005, 05:40 PM
Math library for Free Basic - by Antoni Gual - 01-19-2005, 05:57 PM
Math library for Free Basic - by jdebord - 01-19-2005, 10:05 PM
Math library for Free Basic - by Antoni Gual - 01-19-2005, 10:18 PM
Math library for Free Basic - by adosorken - 01-19-2005, 10:52 PM
Math library for Free Basic - by R@dioman - 01-19-2005, 10:58 PM
Math library for Free Basic - by jdebord - 01-19-2005, 11:39 PM
Math library for Free Basic - by R@dioman - 01-20-2005, 12:08 AM
Math library for Free Basic - by Antoni Gual - 01-20-2005, 01:39 AM
Math library for Free Basic - by relsoft - 01-21-2005, 02:20 PM
Math library for Free Basic - by jdebord - 01-22-2005, 03:27 PM
Math library for Free Basic - by na_th_an - 01-22-2005, 07:24 PM
Math library for Free Basic - by v3cz0r - 01-22-2005, 07:56 PM
Math library for Free Basic - by na_th_an - 01-22-2005, 08:40 PM
Math library for Free Basic - by jdebord - 01-23-2005, 02:07 PM
Math library for Free Basic - by jdebord - 01-31-2005, 02:47 PM
Math library for Free Basic - by jdebord - 02-01-2005, 03:29 PM
Math library for Free Basic - by Antoni Gual - 02-01-2005, 08:49 PM
Math library for Free Basic - by jdebord - 02-01-2005, 11:13 PM
Math library for Free Basic - by retsyo - 02-02-2005, 08:18 AM
Math library for Free Basic - by v3cz0r - 02-02-2005, 10:52 PM
Math library for Free Basic - by jdebord - 02-03-2005, 10:52 PM
Math library for Free Basic - by jdebord - 02-09-2005, 02:21 PM
Math library for Free Basic - by jdebord - 02-09-2005, 02:29 PM
.... - by ulil - 02-10-2005, 10:24 AM
Re: .... - by jdebord - 02-10-2005, 12:30 PM
Math library for Free Basic - by jdebord - 02-14-2005, 05:52 PM
Math library for Free Basic - by BastetFurry - 02-14-2005, 11:08 PM
Physic library - by L_O_J - 02-15-2005, 08:16 AM
Math library for Free Basic - by jdebord - 02-15-2005, 06:07 PM
Math library for Free Basic - by BastetFurry - 02-15-2005, 06:50 PM
Math library for Free Basic - by keeling - 02-18-2005, 10:14 AM
Math library for Free Basic - by jdebord - 02-18-2005, 07:20 PM
Math library for Free Basic - by jdebord - 02-21-2005, 06:32 PM
Math library for Free Basic - by alexsee - 03-05-2005, 08:00 AM
Math library for Free Basic - by keeling - 03-05-2005, 10:50 AM
Math library for Free Basic - by jdebord - 03-05-2005, 11:55 PM
Math library for Free Basic - by keeling - 03-06-2005, 12:41 AM
Math library for Free Basic - by alexsee - 03-06-2005, 04:22 AM
Math library for Free Basic - by jdebord - 03-06-2005, 06:35 PM
Math library for Free Basic - by jdebord - 03-15-2005, 10:47 PM
Math library for Free Basic - by diakin - 03-16-2005, 12:42 AM
Math library for Free Basic - by keeling - 03-16-2005, 02:58 AM
Math library for Free Basic - by v3cz0r - 03-16-2005, 03:39 AM
Math library for Free Basic - by keeling - 03-16-2005, 03:56 AM
Math library for Free Basic - by v3cz0r - 03-16-2005, 05:51 AM
Math library for Free Basic - by jdebord - 03-16-2005, 08:44 PM
Math library for Free Basic - by diakin - 03-17-2005, 06:48 PM
Math library for Free Basic - by keeling - 03-22-2005, 04:42 AM
Math library for Free Basic - by jdebord - 03-22-2005, 02:48 PM
Math library for Free Basic - by jdebord - 03-28-2005, 02:42 PM
Math library for Free Basic - by diakin - 03-29-2005, 02:15 PM
Math library for Free Basic - by jdebord - 04-03-2005, 12:48 PM
Math library for Free Basic - by jdebord - 04-07-2005, 01:21 PM
Math library for Free Basic - by jdebord - 04-30-2005, 09:48 PM
Math library for Free Basic - by dumbledore - 05-04-2005, 09:44 AM
Math library for Free Basic - by jdebord - 05-04-2005, 11:15 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)