Math Function “CEILING (number, significance)” does not work properly?
Example 1: CELING (-1.24)
value is changed to “2” (and should be “-1”)
Example 2: CELING (-1.24, .1)
the value changes to “-1.3” (and should be “-1.2”)
in my opinion
for example, the function “FLOOR (number, significance)” - is working properly. And for negative values - the results of both functions - the same, but must be different.
Example 2: FLOOR (-1.24)
value will be changed to “-2”
Example 3: FLOOR (-1.24, .1)
value will be changed to “-1.3”
What is the reason?
PS
I have checked the performance of the functions in this example:
SU2015 Pro 15.2.685 version of the 64-bit windows7
[quote=“arxutektor, post:1, topic:6269”]
Math Function “CEILING (number, significance)” does not work properly?
Example 1: CELING (-1.24)
value is changed to “2” (and should be “-1”)[/quote]
use Round(number, decimal places)
(though your example, Ceiling(-1.24) should return -2 (which it does for me)
but… Round(-1.24) returns -1
[quote]
Example 2: CELING (-1.24, .1)
the value changes to “-1.3” (and should be “-1.2”)[/quote]
Round(-1.24, .1) will give -1.2
not sure but that’s the way it works with Ceiling in my spreadsheet application (numbers)… or, in that app, the signs for Ceiling have to match… =Ceiling(-1.56, -.1) gives you -1.6
no mixing of pos&neg… =Ceiling (1.654, -.25)
it will give a syntax error if trying to use that.
Yes I Am. Therefore, I believe that there is a incorrect operation of function.
This is - a mathematical function, and its logic should not differ from other programs to mine.
that’s how python works as well.. however, earlier i said “i’m not sure why but this is how it works in my spreadsheet app”.. it’s different there.
i don’t have excel to try but using google.docs:
or trying to use =Ceiling(-1.24, .1) in my spreadsheet app (numbers.app):
so i guess the question becomes.. which spreadsheet or programming language should dynamic component’s Ceiling function be consistent with? because there doesn’t seem to be consistency in general with the function as shown above.
generally, spreadsheets have RoundUp and RoundDown functions (which i believe are missing from DC).. but in numbers, i’d have to do something like if x<0 roundDown(x) else roundUp
in order to get similar functionality as i get with python ceiling..
arxutektor makes a valid point. The “ceiling” function in mathematics is defined differently than the CEILING function in SketchUp DC (which is “The CEILING function rounds a number to the nearest integer or multiple of significance”).
Using Excel 2010, I get the following:
Wikipedia notes:
"Most spreadsheet programs support some form of a ceiling function. Although the details differ between programs, most implementations support a second parameter—a multiple of which the given number is to be rounded to. For example, ceiling(2, 3) rounds 2 up to the nearest multiple of 3, giving 3. The definition of what “round up” means, however, differs from program to program.
Until Excel 2010, Microsoft Excel’s ceiling function was incorrect for negative arguments; ceiling(-4.5) was -5. . This has followed through to the Office Open XML file format. The correct ceiling function can be implemented using “-INT(-value)”. Excel 2010 now follows the standard definition.
The OpenDocument file format, as used by OpenOffice.org and others, follows the mathematical definition of ceiling for its ceiling function, with an optional parameter for Excel compatibility. For example, CEILING(-4.5) returns −4."
the point i was making (which is also being said in the wiki) is that Ceiling doesn’t have consistent behavior across applications… some act the same as DC, some are opposite, then googledocs seems to be a mixture of the two…
personally, i think the ones which do ceiling(-1.25) = -1 are the ones that are doing it ‘correctly’…
or- if sketchupDC were to adopt the OpenDocument file format, you’d hear no complaints out of me
idk, i have 5-6 dynamic components which use the Ceiling function in them but luckily for me, none of them are dealing with negative numbers… i never realized this behavior until arx made this thread.
Thank you for the clarification. I learning DC, and translate into Russian explanations. Check that how it works. That met the discrepancy. I have found a inconsistencies description set forth here:
but do not even know whether to publish them here.
When I try to use only the value in Excel, I get an error:
“You’ve entered too few arguments for this function.”
Here are some more examples:
Since the mathematical definition only deals with the single numerical value and not the significance, implementation of a function that accepts two values is somewhat arbitrary and may not result in the expected outcome. However, for consistency, any computer function that uses an existing math operator with the same name should implement the code in a manner that is consistent with its namesake (IMHO).
As noted above for other languages, compare to the Ruby math function “ceil”:
yeah, i don’t disagree with that… the problem however is that there’s no consistency with the namesake as far as i can gather…
here’s another inconsistency… in excel, you’re saying you can’t use =Ceiling(-1.24)…
with excel online, you can (and it gives the results consistent with the programming languages)
that’s saying:
if it’s a positive number, use Ceiling
if it’s a negative number, get the absolute value of it, then get the floor, then make it negative