Jump to content

Problems with data types,number representation


faslan

Recommended Posts

1)A^2-B^2 WE CAN WRITE THIS AS (A+B)(A-B) but if A,B are two floating point numbers these calculations may yield different results
why this
under what circumstances does a difference between two calculators arise

 

 

 

 

 

2)why it's hard to ( time and hardware complexity )to add two floating point numbers than integer numbers

 

 

 

3) is my examples right or wrong
integers = 25 ,-14, 11bin, A7Hex,17oct
floating points 12.14 -7.33 -11.11bin 74.12 oct

 

Link to comment
Share on other sites

Floating point numbers in the computer are represented with a finite number of bits (double precision - 64). When multiplying two numbers the product would require more than 64 bits. The extra ones are dropped, so the result is not exact.

Quite the same can be said about integers - too big integer will cause overflow and completely wrong result.

In machine code it can be detected by checking overflow flag in CPU status register.

http://en.wikipedia.org/wiki/Overflow_flag

But in high level languages, not possible to detect a posteriori.

Edited by Sensei
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.