R
RN1
The book I am referring to learn ASP states the following about the
Int & Fix VBScript Maths functions:
=========================================
Both Int & Fix return the integer portion of the number but the
difference lies in handling negative numbers. Int returns the first
integer lesser than or equal to the number whereas Fix returns the
first integer greater than or equal to the number.
=========================================
I guess using the term "integer portion" would have been more
appropriate than the term "first integer", isn't it?
Nevertheless, isn't the difference stated above wrong to some extent?
This is because the output of passing a negative number to the Int
function (assuming that the number is a decimal/floating point number
& that all the integers after the decimal point are not 0) will ALWAYS
be LESSER than the integer portion of the negative number; the output
will NEVER be EQUAL to the negative number. For e.g. both
Int(-61.0003)
&
Int(-61.9999)
will return -62 which is LESSER than the integer portion of both
-61.0003 & -61.9999; it won't return -61 which is EQUAL to the integer
portion of both the negative numbers -61.0003 & -61.9999. Of course
Int(-61.0000)
&
Int(-61)
will return -61.
Also the output of passing a negative number to the Fix function (be
it a decimal/floating point number or a whole number) will ALWAYS be
EQUAL to the integer portion of the negative number; its output will
NEVER be GREATER than the integer portion of the negative number. For
e.g.
Fix(-61.0003)
Fix(-61.9999)
Fix(-61.0000)
&
Fix(-61)
will return -61 which is EQUAL to the integer portion of the 4
negative numbers; it won't return -60 which is GREATER than the
integer portion of the 4 negative numbers.
Please correct me if I am wrong.
Thanks,
Ron
Int & Fix VBScript Maths functions:
=========================================
Both Int & Fix return the integer portion of the number but the
difference lies in handling negative numbers. Int returns the first
integer lesser than or equal to the number whereas Fix returns the
first integer greater than or equal to the number.
=========================================
I guess using the term "integer portion" would have been more
appropriate than the term "first integer", isn't it?
Nevertheless, isn't the difference stated above wrong to some extent?
This is because the output of passing a negative number to the Int
function (assuming that the number is a decimal/floating point number
& that all the integers after the decimal point are not 0) will ALWAYS
be LESSER than the integer portion of the negative number; the output
will NEVER be EQUAL to the negative number. For e.g. both
Int(-61.0003)
&
Int(-61.9999)
will return -62 which is LESSER than the integer portion of both
-61.0003 & -61.9999; it won't return -61 which is EQUAL to the integer
portion of both the negative numbers -61.0003 & -61.9999. Of course
Int(-61.0000)
&
Int(-61)
will return -61.
Also the output of passing a negative number to the Fix function (be
it a decimal/floating point number or a whole number) will ALWAYS be
EQUAL to the integer portion of the negative number; its output will
NEVER be GREATER than the integer portion of the negative number. For
e.g.
Fix(-61.0003)
Fix(-61.9999)
Fix(-61.0000)
&
Fix(-61)
will return -61 which is EQUAL to the integer portion of the 4
negative numbers; it won't return -60 which is GREATER than the
integer portion of the 4 negative numbers.
Please correct me if I am wrong.
Thanks,
Ron