Solved

Q for rosefire:  Neg 0s in IEEE 754

Posted on 1998-12-15
7
320 Views
Last Modified: 2012-05-04
Hi rosefire;

I gave the points for the last question to ozo, but I am interseted in what you brought up.  Could you give me more info on what types of problems an application would have with a negative zero representation?

Thanks,

Matt
0
Comment
Question by:MatthewL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 3

Accepted Solution

by:
rosefire earned 50 total points
ID: 1013697
Floating-point arithmetic on digital computers is inexact. The 23 bits plus the hidden bit of mantissa in a 32-bit floating-point number equates to roughly  7 significant digits. As I am sure you know, floating-point systems differ from real numbers in that they have gaps between each number. If a number is not exactly representable, then it must be approximated by one of the nearest representable values.  This can be positive zero, or it can be negative zero.

Because the same number of bits are used to represent all normalized numbers, the smaller the exponent, the greater the proximity  of representable numbers. For example, there are approximately 8.3 million single-precision numbers between 1.0 and 2.0, while there are only about 8k between 1023.0 and 1024.0.

On any computer, mathematically equivalent expressions can produce different results. In this example, Z and Z1 will typically have different values because (1/Y) or 1/7 is not exactly representable in binary floating-point:

REAL X, Y, Y1, Z, Z1
DATA X/77777/, Y/7/
Y1 = 1 / Y
Z = X / Y
Z1 = X * Y1
IF (Z .NE. Z1) PRINT *, 'Not equal!'
END

A programmer has to keep the inexact nature of the floating point number in mind when writing a program where rounding can take you to either to a negative or positive zero when rounding.  Unexpected cases can arise.

The vast majority of problems with positive and negative zero representations are ones that are a result of programmers failure to handle the negative zero rounding case properly.  Programs will work and seem bug free but make mistakes with corner cases that arise infrequently.    Intel got burned on such a rounding problem pretty good if you recall.

Hope that helps.  If you have any further questions, let me know.

RoseFire
0
 
LVL 84

Expert Comment

by:ozo
ID: 1013698
The problem of inexactness in floating point representations exists regardless of how many kinds of zero there are.
0
 
LVL 1

Author Comment

by:MatthewL
ID: 1013699
Once again thanks to you both.

So does this mean the potential problem would be with a JS or JL instruction incorrectly ( in our interpretation ) jumping?

Matt
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 3

Expert Comment

by:rosefire
ID: 1013700
I don't understand your last question.  I don't know the particulars of the problem with the long and short jump problem you refer to.

RoseFire
0
 
LVL 1

Author Comment

by:MatthewL
ID: 1013701
Hi rosefire;

I was just trying to think of where the problems would occur.  So I thought maybe on JS ( jump on sign) would jump on a negative 0 but not on a positive 0 and therefore create an inconsistency.  Is this a correct interpretation?

Matt
0
 
LVL 3

Expert Comment

by:rosefire
ID: 1013702
Actually, I don't know compilers well enough to answer that, but i would hope that a complier would know the difference between negative and positive zero.  Now, if you are an assembly language programmer, the outcome could be ambiguous but he hardware should ignore the sign bit in doing the compare if it is IEEE compliant.

Hope that helps.

RoseFire
0
 
LVL 1

Author Comment

by:MatthewL
ID: 1013703
Thanks,


Matt
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
avi rca in to vga out 4 57
SBS 2011 Backup Drive 8 108
Audio and image stuttering issue 24 161
Cisco 2960 unable to add SFP modules to device 9 136
In this article we have discussed the manual scenarios to recover data from Windows 10 through some backup and recovery tools which are offered by it.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question