C代写:CST8233 Floating Point Spy

代写浮点数转换器,按要求把浮点数转换成二进制数、大端十六进制以及小端十六进制。

Purpose

A utility application to show a real number in its float, double, hexadecimal and binary representations - to automate what is done manually in class.

Algorithm

Write a utility program named ass1 that will enable you to view the bit fields used to represent floatingpoint numbers, both float and double. While the user wishes to continue, the user is asked to enter the next number. The user can choose either float or double type. The binary and hexadecimal representations of that number are then presented (you may find bitwise operations in C useful for this). Example output is shown at the end. Yours must look the same. If dynamic memory allocation is used, it must be released when the application terminates.

See the Marking Sheet for how you can lose marks, but you will lose at least 60% if: it fails to build in Visual Studio 2013, it crashes in normal operation, it doesn’t produce the example output.

Set up a Win32 console project in Visual Studio 2013 with the name ass1. Write the code to implement the application as described above.

What to Submit

Use the Submission on Blackboard to submit this assignment as a zip (not RAR) file containing only the source code ass1.cpp file. The name of the zipped folder must contain your name as a prefix so that I can identify it, for example using my name the file would be tyleraAss1CST8233.zip. It is also vital that you include the Cover Information (as specified in the Submission Standard) as a file header in your source file so the file can be identified as yours. Use comment lines in the file to include the header.

Before you submit the code,

  • check that it builds and executes in Visual Studio 2013 as you expect - if it doesn’t build for me, for whatever reason, you get a deduction of at least 60%.
    0 make sure you have submitted the correct file - if I cannot build it because the file is wrong or missing from the zip, even if it’s an honest mistake, you get 0.
  • there’s a late penalty of 25% per day. Don’t send me file(s) as an email attachment - it will get 0.

Example output - yours must look identical:

1 = convert a float
2 = convert a double
3 - quit
1
Please enter the number to convert: 12.5

float number is         12.500000
Binary:                 0100 0001 0100 1000 0000 0000 0000 0000
Big-endian Hex:         41 48 00 00
Little-endian Hex:      00 00 48 41

1 = convert a float
2 = convert a double
3 - quit
1
Please enter the number to convert: -1.0

float number is         -1.000000
Binary:                 1011 1111 1000 0000 0000 0000 0000 0000
Big-endian Hex:         BF 80 00 00
Little-endian Hex:      00 00 80 BF

1 = convert a float
2 = convert a double
3 - quit
2
Please enter the number to convert: -1.0

double number is        -1.000000
 Binary:
1011 1111 1111 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

Big-endian Hex:         BF F0 00 00 00 00 00 00
Little-endian Hex:      00 00 00 00 00 00 F0 BF

1 = convert a float
2 = convert a double
3 - quit
1
Please enter the number to convert: 1.0e39

float number is         1.#INF00
Binary:                 0111 1111 1000 0000 0000 0000 0000 0000
Big-endian Hex:         7F 80 00 00
Little-endian Hex:      00 00 80 7F

1 = convert a float
2 = convert a double
3 - quit
1
Please enter the number to convert: 1.0e38

float number is         99999996802856925000000000000000000000.000000
Binary:                 0111 1110 1001 0110 0111 0110 1001 1001
Big-endian Hex:         7E 96 76 99
Little-endian Hex:      99 76 96 7E

1 = convert a float
2 = convert a double
3 - quit
1
Please enter the number to convert: 0.0
 float number is         0.000000
Binary:                 0000 0000 0000 0000 0000 0000 0000 0000
Big-endian Hex:         00 00 00 00
Little-endian Hex:      00 00 00 00

1 = convert a float
2 = convert a double
3 - quit
1
Please enter the number to convert: 2.0e-45

float number is         0.000000
Binary:                 0000 0000 0000 0000 0000 0000 0000 0001
Big-endian Hex:         00 00 00 01
Little-endian Hex:      01 00 00 00

1 = convert a float
2 = convert a double
3 - quit