My Project
Typedefs | Functions
flt32.h File Reference

Defines interface of flt32.c functions (do not modify) More...

Go to the source code of this file.

Typedefs

typedef int flt32
 

Functions

int flt32_get_sign (flt32 x)
 
int flt32_get_exp (flt32 x)
 
int flt32_get_val (flt32 x)
 
void flt32_get_sve (flt32 x, int *sign, int *val, int *exp)
 
int flt32_leftmost_1 (int value)
 
flt32 flt32_abs (flt32 x)
 
flt32 flt32_negate (flt32 x)
 
flt32 flt32_add (flt32 x, flt32 y)
 
flt32 flt32_sub (flt32 x, flt32 y)
 

Detailed Description

This file defines the interface to a C file flt32.c that you will complete. You will learn how to do floating point arithmatic 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. You may reuse the code you wrote for field.c assignment. Or, you may use the provided file field.o in place of your code. That file is a compiled version of field.c written by an instructor. You will only be submitting one files (flt32.c).

Typedef Documentation

typedef int flt32

Whenever flt32 is used, the value is an integer in the IEEE floating point 32 bit standard.

Function Documentation

flt32 flt32_abs ( flt32  x)

Absolute value of the argument. This can be done with a simple bit manipulation operation or with your field functions. No conditionals are required.

Parameters
xsome pattern of bits (may be a IEEE floating point value)
Returns
the absolute value of the parameter
Todo:
Implement in flt32.c based on documentation contained in flt32.h
flt32 flt32_add ( flt32  x,
flt32  y 
)

Add two floating point values

Parameters
xan integer containing a IEEE floating point value
yan integer containing a IEEE floating point value
Returns
x + y. Your code needs to account for a value of 0.0, but no other special cases (e.g. infinities)
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
xthe integer containing a IEEE floating point value
Returns
the exponent of the argument, after removing bias
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
xthe 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
void flt32_get_sve ( flt32  x,
int *  sign,
int *  val,
int *  exp 
)

Get the sign, value, and exponent in a single call. You will use

Parameters
xthe integer containing a IEEE floating point value
signpointer to location where sign will be stored
valpointer to location where value will be stored
exppointer to location where exponent will be stored C pointers to return values.
Todo:
Implement in flt32.c based on documentation contained in flt32.h
int flt32_get_val ( flt32  x)

Extract the digits of the argument

Parameters
xthe integer containing a IEEE floating point value
Returns
the 24 bits representing the value (includes the implicit 1)
Todo:
Implement in flt32.c based on documentation contained in flt32.h
int flt32_leftmost_1 ( int  value)

Extract the position of the leftmost 1 in the argument's bits

Parameters
valuethe integer
Returns
-1 if the value is 0, otherwise the position (0 to 31) of the left most 1 bit.
Todo:
Implement in flt32.c based on documentation contained in flt32.h
flt32 flt32_negate ( flt32  x)

Negate the argument. This can be done with a simple bit manipulation function (think about the C xor operator (^) or with your field functions.

Parameters
xthe integer containing a IEEE floating point value
Returns
the negation of the value
Todo:
Implement in flt32.c based on documentation contained in flt32.h
flt32 flt32_sub ( flt32  x,
flt32  y 
)

Subtract to floating point values

Parameters
xan integer containing a IEEE floating point value
yan integer containing a IEEE floating point value
Returns
x - y. Your code needs to account for a value of 0.0, but no other special cases (e.g. infinities)
Todo:
Implement in flt32.c based on documentation contained in flt32.h