Floating point representation in IEEE 754 format The following code takes a decimal number and gives its IEEE 754 floating point representation. However, the code is not complete and I am totally fine because it does the job for me: 


It does not consider negative numbers. 
The input number is not a fraction. Its always in the form xx.yy
As of now, it does not give representation in 32-bit or 64-bit format, it just gives exponent and significant value.




function toBinary (decimal) {
    return decimal.toString(2);
}

function getIntegerPart (binary){
    return binary.slice(0, binary.indexOf('.'));
}

function getFractionalPart (binary){
    return binary.slice(binary.indexOf('.')+1);
}

function toNormalize (binary) {
    var normalizedRep = new Object();
    exponentValue = binary.indexOf('.')-1;
    floatPosition = binary.indexOf('.');
    normalizedRep.floatRep = binary[0]+ '.' + binary.slice(1, floatPosition) + binary.slice(floatPosition+1); 
    normalizedRep.exponentValue = exponentValue;
    normalizedRep.floatPosition = floatPosition;
    return normalizedRep;
}

function getSignificand (normalizedRep) {
    return normalizedRep.floatRep.slice(normalizedRep.floatRep.indexOf('.')+1);
}

function twosComp() {
    var decimal = 15.22;
    var binary = toBinary(decimal);
    var integerPart = getIntegerPart(binary);
    var fractionalPart = getFractionalPart(binary);
    var floatPosition = binary.indexOf('.');
    var normalizedRep = toNormalize(binary);
    var significand = getSignificand(normalizedRep);
    var exponentValue = normalizedRep.exponentValue;

    console.log(binary);
    console.log(floatPosition);
    console.log(normalizedRep.floatRep);
    console.log(significand);
    console.log(exponentValue);
}
I just don't get what you're trying to do. JavaScript does not know of integers, floats or any other numeric type, except for Number.
This data-type just happens to be a 64bit IEEE754 floating point value (or double in most strong-typed languages). This is clearly described in the official language specs

primitive value corresponding to a double-precision 64-bit binary format IEEE 754 value
NOTE A Number value is a member of the Number type and is a direct representation of a number.

So a float representation of a number is the number itself. If you want n number of significant digits, then there's a handy method for that:
var num = 123.321;
console.log(num.toFixed(2));//123.32

If you want the integer part of a non-integer number:
parseInt(num, 10);//123 (best to specify the radix)

If you want the remainder, either one of the following approaches will do:
num - parseInt(num, 10);
//or
num%1//modulo || remainder of division by 1

Note that in this last case, you will see the rounding errors of the IEE754 spec show up, so:
num = 123.321;
//get length of string rep for total number - int length,  -1 for .
var fix = (&quot;&quot;+num).length - (&quot;&quot;+parseInt(num, 10)).length - 1;
(num%1).toFixed(fix);

Might be required.
As far as the fraction representation of a number is concerned, that is going to take some work. Thankfully, it's all been done before and the code is available on github.
I don't know what you mean by: &quot;It does not consider negative numbers&quot;, because, like I said before: there is but one type for numbers in JS, and so it's always signed. Just use the absolute value, and keep track of the what the number was initially (prositive or negative) like so:
function processNumber(num)
{
    var sign = !(num &gt; 0);//bool, true if num is negative
    var workVal = Math.abs(num);//get absolute value
    var returnObj = {};
    returnObj.intVal = parseInt(workVal, 10);
    returnObj.floatPart = (workVal%1).toFixed((&quot;&quot;+workVal).length - (&quot;&quot;+returnObj.intVal).length - 1);
    returnObj.fixed2 = workVal.toFixed(2);
    //and so on...
    if (sign === true)
    {
        for (prop in returnObj)
        {
            if (returnObj.hasOwnProperty(prop))
            {//they're all strings, just prepend the sign...
                returnObj[prop] = '-' + returnObj[prop];
            }
        }
    }
    return returnObj;