Integrated M. Tech students must code the function in C Language.
def inttobin(num) :
# This function returns the binary representation of a
# given POSITIVE INTEGER
return bnum
def sinttobin(num, bits=8) :
# This number returns the binary representation of a
# given number (POSITIVE or NEGATIVE) using signed bit
# representation. The number of bits for representing the
# number is given by the argument bits (default 8). Thus,
# if the function is called as
# sinttobin(-11, 6)
# it returns 1001011 (6 bits for the number and a sign bit)
return bnum
def floattoieee(fnum) :
# This function returns the 32-bit single precision
# IEEE floating point representation of the given number
# If the function is called as
# floattoieee(22.0)
# it returns 01000001101100000000000000000000
return ieee754
def printIEEE(fnum) :
# This function does not return anything but prints the
# IEEE754 representation in a human understandable format
# If the function is called as
# printIEEE(22.0)
# its output is
# Sign: 0
# Exponent: 131 (real exponent: 4)
# Mantissa: 0.375
# 22.0 = 1.375 x 2^4
return
def ieeetofloat(ieeerep) :
# This function takes a number in IEEE 32-bit representation
# and returns its decimal value.
# If the function is called as
# ieeetofloat(11000001101100000000000000000000)
# it returns -22.0
return num
def pairtofloat(mantissa, exponent, s=0) :
# This function takes the mantissa and exponent values
# separately and returns the decimal value
# If the function is called as
# pairtofloat(0110, 4)
# it returns 22.0
# Note that the mantissa need not be given as 23 bits - you
# must pad the necessary 0s. If s = 1, it is a negative number
return num