Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 2nd, 2007, 6:17 PM   #1
harryc
Newbie
 
Join Date: Sep 2007
Posts: 8
Rep Power: 0 harryc is on a distinguished road
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
harryc is offline   Reply With Quote
Old Sep 2nd, 2007, 6:30 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Sep 2nd, 2007, 6:35 PM   #3
harryc
Newbie
 
Join Date: Sep 2007
Posts: 8
Rep Power: 0 harryc is on a distinguished road
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
harryc is offline   Reply With Quote
Old Sep 2nd, 2007, 7:03 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Sep 2nd, 2007, 7:09 PM   #5
harryc
Newbie
 
Join Date: Sep 2007
Posts: 8
Rep Power: 0 harryc is on a distinguished road
do u understand my question?? can u help me out?? if u cant its ok..i dont need unrelated replies to my problem..THX
harryc is offline   Reply With Quote
Old Sep 2nd, 2007, 8:22 PM   #6
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 321
Rep Power: 4 andro is on a distinguished road
Send a message via AIM to andro
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/
andro is offline   Reply With Quote
Old Sep 2nd, 2007, 9:57 PM   #7
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
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.
Booooze is offline   Reply With Quote
Old Sep 3rd, 2007, 5:17 PM   #8
harryc
Newbie
 
Join Date: Sep 2007
Posts: 8
Rep Power: 0 harryc is on a distinguished road
thx Booooze
harryc is offline   Reply With Quote
Old Sep 4th, 2007, 2:12 PM   #9
Fall Back Son
Professional Programmer
 
Join Date: Oct 2006
Posts: 312
Rep Power: 3 Fall Back Son is on a distinguished road
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.
Fall Back Son is offline   Reply With Quote
Old Sep 4th, 2007, 2:43 PM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC