realbasic-nug
[Top] [All Lists]

Re: Division by zero

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Division by zero
From: Mathieu Langlois <realsoftlists at gmail dot com>
Date: Thu, 31 Mar 2005 02:40:14 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=UU3T/xJrugIpuEoone2YmxuB0l00RzZbYK+tYL1xn731xqIU2ngEGYGYkIkgcP2BpgLvV7tYAaL/ZFsYNE7zg+v4YR8SnltQwcHa4DRnQeygN9KG4shV3Fwy9FoUtyLg0EEXFI2CHaUzA87Y424cbOONFhJbmMW5HPfWX1zIB1w=
References: <20050330225223 dot 58855 dot qmail at web54101 dot mail dot yahoo dot com> <845d944ba97153a23e0eb86e879ad58e at realsoftware dot com> <91d7717e5da93dd9b099e1db78ed0714 at indeq dot com> <5d7ca37e05033017347ccd3575 at mail dot gmail dot com> <a6c89344279e671b93407f78c6e95317 at indeq dot com> <c56b50f25e9e4947c4b8ea8118f5b392 at realsoftware dot com>
Check this out on page 388.  It's the IBM PPC 32bit documentation
describing the divw instruction:
http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF778525699600719DF2/$file/6xx_pem.pdf

Quote: "If an attempt is made to perform either of the
divisions—0x8000_0000 / -1 or
<anything> / 0, then the contents of rD are undefined, as are the
contents of the LT, GT,
and EQ bits of the CR0 field (if Rc = 1). In this case, if OE = 1 then
OV is set."

As you can see, the result from the instruction on a division by 0 is
undefined, and there are no error flags whatsoever.  If someone wants
to research the Intel documentation, I suspect the behavior is
similar.  RB is simply passing the instruction to the processor and
returning the result.

Should RS implement internal checkings?  Maybe.  At the cost of
performance?  Not if it can't be disabled.

Math

On Wed, 30 Mar 2005 20:22:03 -0600, Jonathan Johnson
<jonj at realsoftware dot com> wrote:
> REALbasic simply compiles in a divw instruction on PPC for integer
> division, and the equivalent on x86.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>