Changeset 1d83419 in mainline for softfloat/generic/conversion.c


Ignore:
Timestamp:
2006-02-24T17:27:19Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ba5870d
Parents:
a82695c
Message:

32 bit integers to float type conversions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • softfloat/generic/conversion.c

    ra82695c r1d83419  
    3030#include "conversion.h"
    3131#include "comparison.h"
     32#include "common.h"
    3233
    3334float64 convertFloat32ToFloat64(float32 a)
     
    386387}       
    387388
    388 
     389       
     390/** Convert unsigned integer to float32
     391 *
     392 *
     393 */
     394float32 uint32_to_float32(__u32 i)
     395{
     396        int counter;
     397        __s32 exp;
     398        float32 result;
     399       
     400        result.parts.sign = 0;
     401        result.parts.fraction = 0;
     402
     403        counter = countZeroes32(i);
     404
     405        exp = FLOAT32_BIAS + 32 - counter - 1;
     406       
     407        if (counter == 32) {
     408                result.binary = 0;
     409                return result;
     410        }
     411       
     412        if (counter > 0) {
     413                i <<= counter - 1;
     414        } else {
     415                i >>= 1;
     416        }
     417
     418        roundFloat32(&exp, &i);
     419
     420        result.parts.fraction = i >> 7;
     421        result.parts.exp = exp;
     422
     423        return result;
     424}
     425
     426float32 int32_to_float32(__s32 i)
     427{
     428        float32 result;
     429
     430        if (i < 0) {
     431                result = uint32_to_float32((__u32)(-i));
     432        } else {
     433                result = uint32_to_float32((__u32)i);
     434        }
     435       
     436        result.parts.sign = i < 0;
     437
     438        return result;
     439}
     440
     441
     442float32 uint64_to_float32(__u64 i)
     443{
     444}
     445
     446float32 int64_to_float32(__s64 i)
     447{
     448        float32 result;
     449
     450        if (i < 0) {
     451                result = uint64_to_float32((__u64)(-i));
     452        } else {
     453                result = uint64_to_float32((__u64)i);
     454        }
     455       
     456        result.parts.sign = i < 0;
     457
     458        return result;
     459}
Note: See TracChangeset for help on using the changeset viewer.