Question

Write a short java program to convert decimal numbers to 32 bit FPN's

Write a short java program to convert decimal numbers to 32 bit FPN's

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Java code:

import java.util.*;
public class Main
{
   private static String binary32format( float value )
{
int iBits = Float.floatToIntBits(value);
String binary32 = Integer.toBinaryString(iBits);
return binary32;
}   
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("Enter decimal number :");
int decimal = s.nextInt();
String str32 = binary32format(decimal);
System.out.print("32 bit Format of decimal number "+decimal+" is :");
System.out.println( str32 );

  
}
}

Execution screenshot:

Add a comment
Know the answer?
Add Answer to:
Write a short java program to convert decimal numbers to 32 bit FPN's
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT