WTF: 4 divided by 7 = 0, huh?!?

BlitzMax Forums/BlitzMax Programming/WTF: 4 divided by 7 = 0, huh?!?

Hi,

Max does indeed work a lot like c/c++/java/c# (and pretty much every language I've ever used), but I'd hesitate to say this means it's necessarily 'right'.

In Max/C/C++ etc, types are determined 'bottom up' - ie: to determine the type of an expression, you first determine the type of it's sub-expressions, and so on recursively in a 'bottom up' manner.

But another option would be calculate type 'top down' - ie: an expression is evaluated with a type passed down from a super-expression.

You'd need a 'root' type to drive everything, but this would just be either the type of a variable if the expression was for an assignment, the type of a function parameter if the expression was for a function call, type 'Int' if the expression is for an array index and so on.

This way, you could indeed "Print 5/10" and get ".5" back, which I think would be pretty cool.

There are apparantly other benefits to this technique, including more precise math ops, but before anyone gets carried away this will not be appearing in Max as it would affect a lot of existing code!