Math: Add floor() and ceiling() functions
Posted: Mon Dec 20, 2010 2:56 am
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Debug Round(f.f, #PB_Round_Up)
Debug Round(f.f, #PB_Round_Down)
Code: Select all
Macro floor(x)
Round(x, #PB_Round_Down)
EndMacro
Macro ceiling(x)
Round(x, #PB_Round_Up)
EndMacro
For i = 1 To 40
f.f = (i - 20) / 4
Debug "i: " + StrF(f) + ", up:" + Str(ceiling(f)) + ", down:" + Str(floor(f))
Next
Can you please post some code that demonstrates the problem?IdeasVacuum wrote:It does not seem to have the precision required when using doubles.
Do you mean that the value of the number hovers around the integer value, sometimes higher and sometimes lower, so that when you round it up or down it goes the wrong way?IdeasVacuum wrote:It does not seem to have the precision required when using doubles. I have a work-around using strings and often the value is going to end-up being a string anyway.