Bug 4093 - [oleo] Calculating 1/1 becomes infinity.
Summary: [oleo] Calculating 1/1 becomes infinity.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1997-07-15 04:40 UTC by mutoh
Modified: 1997-10-31 13:44 UTC (History)
0 users

See Also:


Attachments
file.diff (824 bytes, patch)
1997-07-15 04:40 UTC, mutoh
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mutoh 1997-07-15 04:40:03 UTC
        In FreeBSD, "1./0." becomes infinity without calling function,
        but it becomes "1" with calling function.
        Using oleo's function divide, the value "#INFINITY" becomes "1".
        So 1./1. in a cell under oleo becomes be equal to "#INFINITY".

Fix: Please apply following patch.
How-To-Repeat:         Please input "1/1" in a cell.
        It becomes "#INFINITY".
Comment 1 Bruce Evans 1997-07-15 15:41:35 UTC
>>Description:
>        In FreeBSD, "1./0." becomes infinity without calling function,

This is a bug in gcc.  1./0. should be evaluated at runtime, giving the
result infinity and setting the IEEE exception flags or causing a SIGFPE,
but gcc evaluates it at compile time, giving the result infinitiy and NOT
setting the IEEE exception flags.

>        but it becomes "1" with calling function.

I think this is a bug in oleo.  Dividing by 0 gives undefined behaviour
in ANSI C, so some extension of ANSI C must be used to get defined
behaviour.  The actual (default) behaviour under FreeBSD is to deliver
a SIGFPE.  Ignoring the SIGFPE doesn't fix the problem.  It gives
undefined behaviour in ANSI C and under FreeBSD.  The actual behaviour
for x/0. under FreeBSD is to give the result x and push `0.' onto the
FPU stack.  The stack garbage may cause problems later.

>        Using oleo's function divide, the value "#INFINITY" becomes "1".
>        So 1./1. in a cell under oleo becomes be equal to "#INFINITY".

This seems backwards.  1./1. should not cause any ininities.

The port probably needs to use fpsetmask(0) to get defined (IEEE default)
behaviour.

Bruce
Comment 2 Thomas Gellekum freebsd_committer freebsd_triage 1997-10-31 13:43:55 UTC
State Changed
From-To: open->closed

I added a call to fpsetmask() which seems to fix the problem.