Boost logo

Boost :

From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2000-02-05 14:50:49


Peter Moore

I have used rational which looks good, (using MSVC6 Sp3)
but does not seem to throw exception for divide by zero when I would expect it
to.

         Output as provided - note doesn't trigger exception handling of divide by
zero!

                 1/2+1/2=1/1
                 1/1-1/2=1/2
                 2/1*1/2=1/1
                 1/1/1/2=2/1
                 abs(-1/2)=1/2
                 2 * 2147483647/2=2147483647 (rational: 2147483647/1)
                 pi = 3.14286 (nearly)
                 Press any key to continue

The code is was produced the output as given on the enhanced demo attached.

Output with some more divide by zeros.

1/2+1/2=1/1
1/1-1/2=1/2
2/1*1/2=1/1
1/1/1/2=2/1
abs(-1/2)=1/2
2 * 2147483647/2=2147483647 (rational: 2147483647/1)
pi = 3.14286 (nearly!)
rational<int> z; == 0/1
z = 1/z; Failed to throw divide by zero exception!
z = one/z; Failed to throw divide by zero exception!
rational<int> dz; == 0/1
rational<int> rz = one/zero; == 1/0
rational<int> rz = one/zero; didn't throw exception!
Bad rational, as expected: bad rational: zero denominator
Press any key to continue

Is the problem that normalisation is skipped for \=?
Or is it the half-made compiler?

Thanks

Paul

Dr Paul A. Bristow, hetp Chromatography
4 Victoria Road, Wilmslow, Cheshire SK9 5HN UK
Phone +44 1625 520193 FAX & Voicemail +44 1625 252495
email mailto:pbristow_at_[hidden]




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk