Bill Priess said:
Well, I have to admit that I agree with Daisy. I have personally seen many
posts from her and although some of them are no brainers, for a learner,
she is usually well on track.
Not everyone here is a MVP, MCSE, MCSD. Not everyone has dealt with C/C++
or any other mainstream languages aside from MS ones.
Not everyone claims he knows the language without reading the specs.
As for the specs... most of us who have dealt with any of the mainstream
languages that MS has taken and bastardized (no offense, MSFT, but that is
usually the case) know that the specs are not always clearly written. For
instance, Math.Ceiling does not accept an int as a parameter *according to
the documenation*, but will take and implicitly convert an int to a double
in order to return a double. So, where in the documentation is that
mentioned? A learner who reads MSDN front to back is not going to find
that
It is properly documented in a lot of places. Look at the specifications on
the implicit transformations of valuue types. This is beginners section.
Just look at the documentation, in this case the C# Programmer's reference:
ms-help://MS.NETFrameworkSDKv1.1/csref/html/vclrfimplicitnumericconversion.h
tm
It lists ALL implicit conversions.
Or, if you prefer the language specification:
ms-help://MS.NETFrameworkSDKv1.1/csspec/html/vclrfcsharpspec_6_1_2.htm
The whole chapter 6.1 of the language specifications lists all Implicit
conversions.
Thinking about them is your job.
Putting it mildly - I am happy you arew not a lawyer or a doctor, as not
making your homework would put you into jail pretty fast in these
businesses. If you loose in court, saaying "I wa just trying and never read
the law" is not a good excuse.
information easily, wouldn't you agree? In fact, to a learner,
I dont. I am a SELF-LEARNER. In contray to you, though, I propably took the
two hours to read the langauge specifications FIRST.
Math.Ceiling(180/10) should return 2, but in fact, it doesn't. But,
according to the documentation posted here, it *should*.
No, it should NOT. This is pretty clear to anyone reading the math
documentation AND knowing the basics of how functions are evaluated.
As a matter of fact, here is the documentation from MSDN 2003 (April) which
does not show that an implicit conversion is taking place.
....snipped...
Because it is not part of the method. It is part o the LANGUAGE, and it is
VERY properly documented. Links above. Referring to the method documentation
just shows you have a little brutally said a total disrespect for the
language. It is pretty clear that the INPUT into ceiling used is ONE
float/int/whatever, it is also clear that the mathematical expression is
evaluated FIRST.
NOW - this evaluation follows the rules laid out in.
You may want to try to understand sections:
7.2.6 Numeric promotions
and
7.4.2 Overload resolution
In combination with
7.2.1 Operator precedence and ssociativity
and
2.4.4.2 Integer literals
it is clear that
* 180/10 is evaluated first.
* 180 and 10 are integer literals
* 180 / 10 is performed as a division integer to integer
NOW - the documentation states (7.7.2, btw - Division Operator):
"The division rounds the result towards zero, and the absolute value of the
result is the largest possible integer that is less than the absolute value
of the quotient of the two operands"
So the output of 180 / 10 is clearly defined to be an integer, including the
rounding rules, as both inputs are integers. And THIS is what you put into
the Math.Ceiling method.
Surely all this is not documented in the Math.Ceiling method - it is of no
business to the method. It is basic arithmetic operations performed by the
langauge before the method sees the result of the operation.
Now, with that posted, where does RTFM come into play?
At the moment you learn the LANGUAGE and how it resolves the arithmetic
operation whose output you put into the method you took the freedom to
quote.
Just shows that when you dont know the language you want to program in, the
documentation of the library is of no use, and that no ibrary documentation
saves you from learning the langauge first. References are given through my
whole post, referring to the language specification, which is part of the
MSDN documentation OR can be found in the Framework documentation (less
weighty) under
..NET Framework SDK / Reference / Compiler and Languag Reference / C# / C#
Language Specification
Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)