PB's Typecasting
Posted: Sat Feb 11, 2006 3:32 am
all infos for this post are taken from http://www.xs4all.nl/~bluez/datatalk/pu ... evaluation
I don't like the idea that parameters of called functions influence the typecasting inside an expressionIn the above the expression behind a.f is evaluated as a float, whilst the one behind b.f is evaluated as a doubleCode: Select all
a.f = Cos(z.f)+10*22 b.f = Cos(z.d)+10*22
why is the typecasting not being done in the same order/direction as the calculation? could cause some hard-to-find bugs in many ppl's appsNotice the mathematic priority! It's NOT going to do something like ( 1 + 2 ) / 3 but it does 1 + ( 2 / 3 ). However, it will not start with typing a float as it still works from left to right. The next sample clearly proves that. Notice the different variable outputs...Code: Select all
a.f = 3 b.l = 1 + 2 / a.fCode: Select all
a.f = 3 b.l = 2/3 + 2/a + 2/a c.l = 2/a + 2/a + 2/a d.l = 2/a + 2/3 + 2/3 e.l = 2/3 + 2/3 + 2/a