Defines interface of flt32.c functions (do not modify)
More...
Go to the source code of this file.
This file defines the interface to a C file flt32.c that you will complete. You will learn how to do floating point arithmetic without using any float
variables. Rather you will perform the operations by using the sign, exponent, and digit fields as defined in the IEEE floating Point Standard.
Whenever flt32
is used, the value is an integer in the IEEE floating point 32 bit standard.
Absolute value of the argument. This can be done with a simple bit manipulation operation. No conditionals are required.
- Parameters
-
x | the integer containing a IEEE floating point value |
- Returns
- the absolute value of the parameter
- Todo:
- Implement in flt32.c based on documentation contained in flt32.h
Add two floating point values
- Parameters
-
x | an integer containing a IEEE floating point value |
y | an integer containing a IEEE floating point value |
- Returns
- x + y. Your code needs to account for a value of 0.0 in the operands or the result (or both), but no other special cases (e.g. infinities)
- Todo:
- Implement in flt32.c based on documentation contained in flt32.h
void flt32_get_all |
( |
flt32 |
x, |
|
|
int * |
sign, |
|
|
int * |
exp, |
|
|
int * |
val |
|
) |
| |
Get the sign, exponent, and mantissa in a single call
- Parameters
-
x | the integer containing a IEEE floating point value |
sign | pointer to location where the sign will be stored |
exp | pointer to location where the exponent will be stored |
val | pointer to location where the value will be stored |
- Todo:
- Implement in flt32.c based on documentation contained in flt32.h
int flt32_get_exp |
( |
flt32 |
x | ) |
|
Extract the exponent of the argument
- Parameters
-
x | the integer containing a IEEE floating point value |
- Returns
- the biased exponent of the argument
- Todo:
- Implement in flt32.c based on documentation contained in flt32.h
int flt32_get_sign |
( |
flt32 |
x | ) |
|
Extract the sign of the argument
- Parameters
-
x | the integer containing a IEEE floating point value |
- Returns
- 0 if the value is 0 or positive, 1 if it is negative
- Todo:
- Implement in flt32.c based on documentation contained in flt32.h
int flt32_get_val |
( |
flt32 |
x | ) |
|
Extract the value of the argument
- Parameters
-
x | the integer containing a IEEE floating point value |
- Returns
- the 24 bits representing the mantissa with the implicit 1 on bit 23 (we call this the value). If x represents 0.0, you should still add the implicit 1 to the mantissa
- Todo:
- Implement in flt32.c based on documentation contained in flt32.h
Negate the argument. For example, if the argument represents 2.25, this function should return the IEEE bit pattern for -2.25.
- Parameters
-
x | the integer containing a IEEE floating point value |
- Returns
- the negation of the value. Note that the negation of 0.0 is 0.0 (not -0.0)
- Todo:
- Implement in flt32.c based on documentation contained in flt32.h
Subtract to floating point values
- Parameters
-
x | an integer containing a IEEE floating point value |
y | an integer containing a IEEE floating point value |
- Returns
- x - y. Your code needs to account for a value of 0.0 in the operands or the result (or both), but no other special cases (e.g. infinities)
- Todo:
- Implement in flt32.c based on documentation contained in flt32.h