Re: A89: Divide by Zero problem
[Prev][Next][Index][Thread]
Re: A89: Divide by Zero problem
>I'm working a program with TIGCC that generates up a list by using a random
>number but when I try to use the an equation like this:
>
>(random(99) + 1) / (14 / 100)
>
>I get an error message (from TEOS) saying Divide by zero. What's up with
>this?
Truncation error. 14 / 100 = 0 in integer math. Try:
100 * (random(99)+1) / 14
since, in reality, when dividing by a number less than one, you're
really multiplying by it's inverse.
Nathaniel Gibson
SiCoDe Software
ngibson@ptd.net
http://sicode.ticalc.org
Follow-Ups:
References: