Questions tagged [ieee-754]

IEEE 754 is the most common & widely used floating-point standard, notably the single-precision binary32 aka float and double-precision binary64 aka double formats.

IEEE 754 is the Institute of Electrical and Electronics Engineers standard for floating-point computation, and is the most common & widely used implementation thereof.

As well as formats, IEEE754 also defines the basic operations, + - * / and sqrt, as producing correctly-rounded results (error <= 0.5ulp). Other functions like pow and sin are not required to be as accurate; that's an implementation choice between precision and performance.

This is why many CPU instruction sets only include the basic operations (including sqrt).

1447 questions
-2
votes
1 answer

Difference between ways to compare floating-point numbers

There seems to be many approaches to judge whether two floating-point numbers are identical. Here are some examples I've found: fabs(x - y) < n * FLT_EPSILON * fabs(x) OR fabs(x - y) < n * FLT_EPSILON * fabs(y) fabs(x - y) < n * FLT_EPSILON *…
nalzok
  • 14,965
  • 21
  • 72
  • 139
-2
votes
1 answer

IEEE-754 single precision 1-bit sign 8-bit exponent 23-bit fraction, What is the binary representation of 0.25*2^(-128)?

IEEE-754 single precision 1-bit sign 8-bit exponent 23-bit fraction, What is the binary representation of 0.25*2^(-128)=2^(-130)? by using the formula: exponent-bias=log(given number) and also fraction=-1+(given number)/2^(exponent-bias) doesn't…
avivk
  • 17
  • 2
-2
votes
2 answers

For IEEE 754 double precision numbers, what range with length of 1 contains the most doubles?

Length of a range is equal to Range.Max - Range.Min For example, "[0-1]" and "[3.5-4.5]" are example of length 1 ranges. So what length-1 range(s), if any, has the most double precision numbers? My guess is either [-0.5 - 0.5] or [0-1] but no way of…
Paul Totzke
  • 1,470
  • 17
  • 33
-2
votes
1 answer

Divide a double precision by a single precision (both IEEE 754) in MIPS assembly without FPU

I have to make a program in MIPS assembly that divide a Double precision floating number by a Single precision number (with standard IEEE 754) without using the Floating Pointer Unit. The only thing I can't understand is how handle the mantissa of…
nytmrae55
  • 1
  • 1
-2
votes
1 answer

IEEE floating point Numbers

I studied IEEE floating point number from the following link IEEE floating Point Number In the above article, I am not clear behind the logic of special operation. Why they have decided the special operation in this way (means why Infinity-Infinity…
Jatin Khurana
  • 1,155
  • 8
  • 15
-3
votes
2 answers

Is it true that 0.1 + 0.2 - 0.3 gives a non-zero in IEEE 754, but gives a zero in traditional floating point?

If I use Ruby, and show 0.1 + 0.2 - 0.3: 3.1.2 :001 > 0.1 + 0.2 - 0.3 => 5.551115123125783e-17 And the digits can be shown this way: 3.1.2 :001 > "%0122.120f" % [0.1 + 0.2 - 0.3] =>…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
-3
votes
1 answer

Why quiet NaN is not always quiet and may lead to raising of floating-point exceptions?

Context: the quiet NaN is not always quiet and may lead to raising of floating-point exceptions. Code sample & invocations: see QNAN passed into C standard library functions (ex. llrintf): not clear whether FP exceptions are raised or not. Details:…
pmor
  • 5,392
  • 4
  • 17
  • 36
-3
votes
1 answer

Have computers started storing 0.1 correctly?

While learning about floating point arithmetic, I came across something, I quote: 'a float/double can't store 0.1 precisely". There is a question on SO pointing the same thing and accepted answer is also very convincing. However I thought of trying…
Imad
  • 7,126
  • 12
  • 55
  • 112
-3
votes
1 answer

What is the maximal normalized number and what is the maximal not normalized number that can be represented using IEEE-754 Single?

I would love to understand the answers to these queastions : What is the maximal not normalized number that can be represented using IEEE-754 Single ? What is the maximal normalized number that can be represented using IEEE-754 Single ?
user6812711
  • 45
  • 1
  • 2
-3
votes
1 answer

recovering double value from array of characters with iEEE 754

So I am trying to read data from an STL file in 4 byte increments. Each 4 byte number corresponds to a value for an x,y, or z coordinate. For my purposes, the number doesn't need to be really precise. Storing the value as a double will do. However,…
Evan
  • 1
  • 1
-3
votes
1 answer

Get fractional part of a number using IEEE754

I have a code that works using loop but it's bad imo, because can be simplified. I mean this loop: private static long GetFract(double d) { if (d < 0) return GetFract(-d); d -= Math.Truncate(d); long…
Alex Zhukovskiy
  • 9,565
  • 11
  • 75
  • 151
-3
votes
3 answers

Weird Java Outputs -- Running VM on Mac lion with Eclipse

Does anyone have an idea where my output problem is? I have written a Java program, and run it on VM on Mac lion with Eclipse. Instead of getting 1.41, I got 1.4100000000000001 on my machine. Example: Enter the number of quarter: 4 Enter the number…
user2844217
  • 1
  • 1
  • 1
  • 2
-3
votes
2 answers

why C compiler gets wrong when a[5]==5[a]

Why does this happpens double zero = 0.0; double a[] = { 0,0,0,0,0, zero/zero}; // NaN cout << (a[5] == 5[a] ? "true" : "false") << endl; prints false
Bharat Gaikwad
  • 530
  • 2
  • 5
  • 16
-4
votes
1 answer

How floating-point convert to integer with truncate?

int a = atof("4.60") * 100; int b = atof("6.60") * 100; printf("a:%d",a); //<==== here print a:459 printf("b:%d",b); //<==== here print b:660 In IEEE 754, 4.60 is 4.599999999... and 6.60 is 6.5999999... I expect print b will show 659 too. How does…
-4
votes
2 answers

Why dividing a float by a power of 10 is less accurate than typing the number directly?

When I run printf("%.8f\n", 971090899.9008999); printf("%.8f\n", 9710908999008999.0 / 10000000.0); I get 971090899.90089989 971090899.90089977 I know why neither is exact, but what I don't understand is why doesn't the second match the first? I…
user541686
  • 205,094
  • 128
  • 528
  • 886
1 2 3
96
97