![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2007
Posts: 8
Rep Power: 0
![]() |
How Do I Represent/Convert Floating Point Numbers into IEEE-754
hello everyone,I am new to this programming world and I hope u guys call help in this...I would need a program in JAVA which will convert floating point numbers into IEEE-754 format..for example +1.5 is represented as 00111111110000000000000000000000. Would really appreciate if anyone could help me in this..tHanks in advance
![]() |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
So you are saying that Java uses something other than IEEE-754? What, exactly is your problem? Do, pray, enlighten us.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2007
Posts: 8
Rep Power: 0
![]() |
HEHE..well i would a sample program in java..im very new to this..my problem is tht i want +1.5 To b converted into 00111111110000000000000000000000..i need a sample program for this..thX
|
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I'm sorry. HEHE is not a terrifacly consoling answer. I will give you a hint: accuracy is traded for precision.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Sep 2007
Posts: 8
Rep Power: 0
![]() |
do u understand my question?? can u help me out?? if u cant its ok..i dont need unrelated replies to my problem..THX
|
|
|
|
|
|
#6 |
|
Professional Programmer
|
I understand your problem. I even had to implement something similar to your problem a couple semesters ago, but I'm not going to do your (home?)work for you :/
__________________
http://www.kevinherron.com/ |
|
|
|
|
|
#7 |
|
Expert Programmer
|
You should seriously check out the FAQ and "How to post a question threads". Then give your problem a chance and try and solve it yourself. Post where you get stuck. And remember that Google is your friend.
|
|
|
|
|
|
#8 |
|
Newbie
Join Date: Sep 2007
Posts: 8
Rep Power: 0
![]() |
thx Booooze
|
|
|
|
|
|
#9 |
|
Professional Programmer
Join Date: Oct 2006
Posts: 312
Rep Power: 3
![]() |
I'm not familiar with "IEEE-754". From looking at your example of how 1.5 is represented, it seems that some conversion of "1.5" occurs, or at least an algorithm is used, which turns it into 00111111110000000000000000000000. Well - why don't you attempt a program using that algorithm, then post here if you have problems? I apologize if I'm off-base with the assumptions I just made in this post. However, I doubt anybody is going to do the work for you.
The only small bit of information I can even offer from reading what I read is that positive numbers are represented by the first digit '0' and negatives, '1'. That's one thing you have to take into consideration when writing the pseudocode for your program. |
|
|
|
|
|
#10 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I would suggest you read the IEEE-754 specification. The float comprises 3 sections: a sign bit, an exponent, and a mantissa. The exponent is divided so that it can represent both positive and negative exponents. The mantissa is normalized, which means there is a 1 to the left of the binary point. Since it is always a 1, it is implicit, and not stored.
Your original post implies that Java describes floats in some way that is not IEEE-754 (since you have to convert). If that's the case, you need to do some research and discover what that method is. It should be relatively clear, by now, that we aren't going to do this for you. This is a help forum, not a free software store.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How Do I Represent/Convert Floating Point Numbers into IEEE-754 | harryc | C++ | 5 | Sep 3rd, 2007 3:53 PM |
| Floating point range | kurt | Python | 4 | Apr 10th, 2007 5:13 PM |
| how to print floating point numbers | eax | Assembly | 5 | Apr 17th, 2006 8:10 PM |
| Median/Mode in arrays? {Need help} | Java|Tera | Java | 27 | Nov 29th, 2005 11:50 AM |