Subject Re: [ib-support] IB dumber than a $5 calculator
Author Paul Schmidt
On 30 May 2002 at 3:44, csswa wrote:

>
> I'm not fond of Interbase's casting. Right now I consider
> Interbase's handling of arithmetic to be dumber than a $5
> calculator. Sure, it's great for completely controlling every step of
> the computational process, but is it really necessary to have to CAST
> every single element of formula to ensure correct results?
>
> There's got to be an easier way. Why not just internally cast every
> computed constant/variable to the output variable type? e.g. if the
> result is a double precision then internally cast all parts of the
> computation to a double. If the result is a string, then type all to
> string, etc.

The problem is this:

Take the diameter of an old metal swimming pool I had in the 1970's 18 feet, now I
want the circumference in metres.

'Calc = ' || '18' * .3048 * '3.14' the output variable is a VARCHAR(20)

what it really needs to do is convert the 18 to a double and the 3.14 to a double, do
the math and cast the result to a string, concatenate that to any strings and sanity
check the result for length. In this case the result would be Calc = 17.227296 at
least according to my Canon F-502 calculator.

Paul Schmidt, President
Tricat Technologies
paul@...
www.tricattechnologies.com