Categories:

.NET (961)

C (387)

C++ (185)

CSS (84)

DBA (8)

General (30)

HTML (48)

Java (641)

JavaScript (220)

JSP (109)

JUnit (31)

MySQL (297)

Networking (10)

Oracle (562)

Perl (48)

Perl (9)

PHP (259)

PL/SQL (140)

RSS (51)

Software QA (27)

SQL Server (5)

Struts (20)

Unix (2)

Windows (3)

XHTML (199)

XML (59)

Other Resources:

My floating-point calculations are acting strangely and giving me different answers on different machines.

Q

My floating-point calculations are acting strangely and giving me different answers on different machines.

✍: Guest

A

If the problem isn't that simple, recall that digital computers usually use floating-point formats which provide a close but by no means exact simulation of real number arithmetic. Among other things, the associative and distributive laws do not hold completely; that is, order of operation may be important, and repeated addition is not necessarily equivalent to multiplication. Underflow, cumulative precision loss, and other anomalies are often troublesome.

Don't assume that floating-point results will be exact, and especially don't assume that floating-point values can be compared for equality. (Don't throw haphazard ``fuzz factors'' in, either; Beware that some machines have more precision available in floating-point computation registers than in double values stored in memory, which can lead to floating-point inequalities when it would seem that two values just have to be equal.

These problems are no worse for C than they are for any other computer language. Certain aspects of floating-point are usually defined as ``however the processor does them'' , otherwise a compiler for a machine without the ``right'' model would have to do prohibitively expensive emulations.

This document cannot begin to list the pitfalls associated with, and workarounds appropriate for, floating-point work. A good numerical programming text should cover the basics; (Beware, though, that subtle problems can occupy numerical analysts for years.)

2015-06-29, 745👍, 0💬

Popular Posts:

What is the sequence of UML diagrams in project? First let me say some fact about this question, you...

What Is a TD Tag/Element? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells A "td" elemen...

If cookies are not enabled at browser end does form Authentication work? No, it does not work.

How To Add Column Headers to a Table? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells I...

What is Windows DNA architecture? Note :- If you have worked with classic ASP this question can come...