Floating point number - verify please

In summary, when converting a floating point number to decimal, if the exponent is all 1's, the answer will be infinity unless the mantissa is all 0's, in which case it will be NaN or Not a Number.
  • #1
denian
641
0
if the floatingpoint number is 1111111111111111111111111111111,
the answer should be NaN instead of infinity rite?
 
Physics news on Phys.org
  • #2
Since computers don't know about "infinity", yes.

(Although now, I'm going to waste time pondering what an "infinity rite" could be!)
 
  • #3
sorry. it should be right, not rite. pardon me.

from your statement, i conclude that the exact answer should be infinity.
am i right?

what if, i have this floating point number : 11111111100000000000000000000000
and i am to convert this floating point number to decimal, the answer should be infinity, isn't it?

then can i summarise that if the exponential is all 1's, it will be infinity when converted to decimal?

thank you.
 
  • #4
denian said:
sorry. it should be right, not rite. pardon me.

from your statement, i conclude that the exact answer should be infinity.
am i right?

what if, i have this floating point number : 11111111100000000000000000000000
and i am to convert this floating point number to decimal, the answer should be infinity, isn't it?

then can i summarise that if the exponential is all 1's, it will be infinity when converted to decimal?

thank you.

Whether you convert it to decimal or not does not really matter. In the standard floating point systems (IEEE SP and IEEE DP) there are two special cases for representing Inf and NaN. I believe (though I'm not sure) that both of these have an exponent with only 1's. Which of the cases it is should then be decided by the value of the mantissa.
 
  • #5
tq. btw, i just found this in the internet.

# Infinity is encoded when the exponent field is all 1’s and the mantissa is all 0’s.
# If the exponent contains all 1’s but the mantissa does not contain all 0’s, then this is referred to as NaN or Not a Number.
 

FAQ: Floating point number - verify please

What is a floating point number?

A floating point number is a type of mathematical representation used by computers to store and manipulate real numbers. It consists of a sign, a significand, and an exponent, and allows for a wide range of numbers to be represented, including very large or very small values.

How is a floating point number verified?

A floating point number can be verified by checking its precision, range, and accuracy. Precision refers to the number of digits that can be represented, while range refers to the minimum and maximum values that can be represented. Accuracy refers to how closely the floating point number approximates the real number it is representing.

What is the difference between a floating point number and an integer?

The main difference between a floating point number and an integer is that a floating point number allows for decimal values, while an integer only allows for whole numbers. Additionally, floating point numbers have a wider range of values that can be represented compared to integers.

How do floating point numbers handle rounding errors?

Due to the finite precision of floating point numbers, rounding errors can occur when performing calculations. These errors can accumulate and affect the accuracy of the final result. To handle this, it is important to carefully manage the precision and rounding of floating point numbers during calculations.

Can floating point numbers be compared for equality?

Due to the potential for rounding errors, it is not recommended to compare floating point numbers for exact equality. Instead, it is best to use a tolerance or margin of error when comparing two floating point numbers. This takes into account any small differences caused by rounding errors and allows for a more accurate comparison.

Back
Top