Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Q for rosefire:  Neg 0s in IEEE 754

Posted on 1998-12-15
7
Medium Priority
?
323 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 200 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
Take our survey for a chance to win!

As a valued customer of Targus, we’d like to ask you a few questions about us. As thanks, you will be automatically entered for a chance to win a $500 VISA gift card. To enter, just complete the survey by September 15, 2017.

 
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

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

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

This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
New style of hardware planning for Microsoft Exchange server.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

730 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