Simon Ampleman wrote:
>         (type result) = find the resulting type... bool * int = int..... 
bool * double = double...etc...
>         (type result) r;
>         return r = x.value() * y.value();

Just use J then.

Consider the following:
112233445566778899*223344556677889900

The arguments to * can be represented exactly using a 64 bit int type.

Furthermore, neither argument can be represented exactly using a 64
bit floating point type.

The result (25066729144544320739243035165220100) would take 115 bytes
to represent, so cannot be represented exactly using a 64 bit int type.

In portable C, determining whether or not an integer multiplication
has overflowed is more expensive than performing the multiplication.

As best I can tell, C++ just adds complication -- it doesn't give
you a good way of recognizing when the result of multiplication is 
too big.

-- 
Raul


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to