Question

write a java program that converts a floating point number to the simple model of the...

write a java program that converts a floating point number to the simple model of the floating point

The simple model uses 1 bit for sign, 5 bits for exponents and 8 bits for significand

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

Solution(s):

Java Program

import java.util.Scanner;
public class conversionClass
{
     public static void main(String[]args)
     {
        Scanner scanInput = new Scanner(System.in);
        double decimalNum;
        int valueBit;
        String stringOfBits;
      
        System.out.println("Please enter the decimal that needs to convert in single precision floating point");
      
        decimalNum = scanInput.nextInt();
        float f = (float)decimalNum;
        valueBit = Float.floatToIntBits(f);
        stringOfBits = Integer.toBinaryString(valueBit);
        System.out.println("Single precision floating point:" + stringOfBits);
      
        System.out.println("Please enter the decimal that needs to convert in double precision floating point");
      
        decimalNum = scanInput.nextInt();
         stringOfBits = Long.toString(Double.doubleToLongBits(decimalNum), 2);
        System.out.println("double precision floating point:" + stringOfBits);   
      
     }
}

Add a comment
Know the answer?
Add Answer to:
write a java program that converts a floating point number to the simple model of the...
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
  • 1. Assume we are using the simple model for floating-point representation as given in this book...

    1. Assume we are using the simple model for floating-point representation as given in this book (the representation uses a 14-bit format, 5 bits for the exponent with a bias of 15, a normalized mantissa of 8 bits, and a single sign bit for the number): a) Show how the computer would represent the numbers 100.0 and 0.25 using this floating-point format. b) Show how the computer would add the two floating-point numbers in part a by changing one of...

  • If we use the IEEE standard floating-point single-precision representation (1 sign bit, 8 bit exponent bits...

    If we use the IEEE standard floating-point single-precision representation (1 sign bit, 8 bit exponent bits using excess-127 representation, 23 significand bits with implied bit), then which of the following hexadecimal number is equal to the decimal value 3.875? C0780000 40007800 Oo 40780000 40A80010 The binary string 01001001110000 is a floating-point number expressed using a simplified 14-bit floating-point representation format (1 sign bit, 5 exponent bits using excess-15 representation, and 8 significand bits with no implied bit). What is its...

  • 5p Question 5 Convert the decimal number 9.625 to a floating-point number expressed in the 14-bit...

    5p Question 5 Convert the decimal number 9.625 to a floating-point number expressed in the 14-bit simple model given in your text (1 bit for the sign, 5 bits for exponent using excess-15 notation, and 8 bit mantissa with no implied bit).

  • Assume the following representation for a floating point number 1 sign bit

     Assume the following representation for a floating point number 1 sign bit, 4 bits exponent, 5 bits for the significand, and a bias of 7 for the exponent (there is no implied 1 as in IEEE). a) What is the largest number (in binary) that can be stored? Estimate it in decimal. b) What is the smallest positive number( closest to 0 ) that can be stored in binary? Estimate it in decimal.c) Describe the steps for adding two floating point numbers. d)...

  • Consider a 9-bit floating-point representation based on the IEEE floating-point format, with one sign bit, four...

    Consider a 9-bit floating-point representation based on the IEEE floating-point format, with one sign bit, four exponent bits (k = 4), and four fraction bits (n = 4). The exponent bias is 24-1-1-7. The table that follows enumerates some of the values for this 9-bit floating-point representation. Fill in the blank table entries using the following directions: e : The value represented by considering the exponent field to be an unsigned integer (as a decimal value) E: The value of...

  • Can anyone help me with this please

    1. If the floating-point number storage on a certain system has a sign bit, a 4-bit exponent and a 5-bit significand:       i) What is the largest positive and the smallest positive number that can be stored on this system if the storage is normalized? (Assume no bits are implied, there is no biasing, exponents use two's complement notation, and exponents of all zeros and all ones are allowed.)       ii) What bias should be used in the exponent if we prefer...

  • Write a program in C++ that converts decimal numbers to IEEE Standard 754 Floating Point Single...

    Write a program in C++ that converts decimal numbers to IEEE Standard 754 Floating Point Single Precision. Please include code that converts to single precision and double precision as a second option.

  • In Java Write a program the takes in a number and converts it to binary. Use...

    In Java Write a program the takes in a number and converts it to binary. Use an OOP class approach using class and objects

  • Use a 10-­‐bit model for floating point numbers, where one bit is used for the sign...

    Use a 10-­‐bit model for floating point numbers, where one bit is used for the sign bit, 4 bits are used for the exponent with a bias of 7, and 5 bits are used for the fraction. What is the smallest and largest positive normal value that can be represented?

  • Create a program (java): that reads a 8-bit String input, must be read in as such....

    Create a program (java): that reads a 8-bit String input, must be read in as such. Then convert that string of 1s and 0s to decimal as if it were encoded using the following representations: Unsigned 1's Complement 2's Complement Q(4.4) (2's complement) 1 bit (sign) - 3 bits (exponent: use bias) - 4 bits (significand), implied binary point w/ 1. Also check for 0.... Do not use helper functions, must be done iterating string and modifying an int/long value....

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
ADVERTISEMENT