• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to convert a number to IEEE FPS ?  RSS feed

 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI ALL
I want to know how to convert a number to IEEE FPS

for eg: 2.25


thanks
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain. I can't understand your question.
 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to convert this number 2.25 to IEEE FPS (IEEE floating point standard) like

sign mantissa exponent
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the strictfp keyword isn't an option?
 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am reading the topic on floating point addition ..in that they are shown like this

2.25 is

s e m
0 1000 0000 100 0000 0000 0000 0000 0000

i want to know to know how i can get this value
 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i didn't get that
 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok how can i do it with strictfp .can anyone help
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java floating point numbers *are* in IEEE standard. There is no need to convert a Java number to IEEE.

Of course, I may have misunderstood your question.

Henry
 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh i am sorry actually i want to know how to represent that number in IEEE FPS
for eg: 2.25
how to represent this number using mantissa exponent and all

actually i was trying to add 2.25 and 1.340625


thanks
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anto telvin Mathew:
oh i am sorry actually i want to know how to represent that number in IEEE FPS
for eg: 2.25
how to represent this number using mantissa exponent and all

actually i was trying to add 2.25 and 1.340625


thanks



Unfortunatly, it is *not* easy. In fact, it is annoyingly harder than it should have been. There is normalization, biasing, special numbers, etc. Anyway, if you really want to understand floating point numbers at the bit level, here is a reference for it....

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

Henry
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to get a copy of a computer hardware book; I have Alan Clements, Principles of Computer Hardware 3/e, Oxford: OUP (2000; there is a 4th edition from about 2006) and it is on page 184-194.
Or this Wikipedia page is quite good.
There is a mention of IEEE754 format in the Java Language Specification, but it is difficult to understand.
 
Anto Telvin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anto telvin Mathew:
thanks
You're welcome.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's wrong with, e.g., java.lang.Float.floatToRawIntBits() ? It returns the 32 bits of the float as an int; then all you have to do is interpret them (i.e., read out the bits that are the exponent, the mantissa, etc.)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!