#70205 - 2002-09-24 03:55 PM
Re: Floating Point - Should this simple expression work ?
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
|
|
Top
|
|
|
|
#70206 - 2002-09-24 03:56 PM
Re: Floating Point - Should this simple expression work ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Because each expression is considered on it's own merits, and the 600*0.5 expression will be evaluated before the 0.0+() expression.
(0.0+600)*0.5 should give you 300 though.
We went through this pretty exhaustively with some good examples, but for the life of me I can't get the search engine to turn them up
Beware however that one of the release candidates had a bug in the precedence when using "NOT"
{edit} Good grief! a veritable flood! {/edit} [ 24. September 2002, 15:58: Message edited by: Richard Howarth ]
|
|
Top
|
|
|
|
#70211 - 2002-09-24 04:14 PM
Re: Floating Point - Should this simple expression work ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
quote: Kixtart processes math expressions in a strictly left to right progression
Not quite right, this is only true where the operators have the same precedence.
KiXtart obeys standard operator preference, so in the expression:
code:
"10" + 5 * 2.5 = "1010"
Will give the result "1010", as the multiplication will be evaluated first due to operator precedence.
As the first number is an integer "5", the "2.5" is converted to an integer and the multiplication takes place, resulting in an integer "10".
Now, the addition may take place and the result is a string, because the first element in the expression is a string. This means a catenation "10" + "10" = "1010"
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|