Changeset 7e557805 in mainline


Ignore:
Timestamp:
2005-12-20T12:48:15Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e649dfa
Parents:
b5440cf
Message:

Some new functions implemented in softfloat lib.

Location:
softfloat
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • softfloat/generic/comparison.c

    rb5440cf r7e557805  
    4040};
    4141
     42inline int isFloat32Infinity(float32 f)
     43{
     44        return ((f.parts.exp==0xFF)&&(f.parts.mantisa==0x0));
     45};
     46
     47/**
     48 * @return 1, if both floats are equal - but NaNs are not recognized
     49 */
     50inline int isFloat32eq(float32 a, float32 b)
     51{
     52        return ((a==b)||(((a.binary| b.binary)&0x7FFFFFFF)==0)); /* a equals to b or both are zeros (with any sign) */
     53}
     54
     55/**
     56 * @return 1, if a>b - but NaNs are not recognized
     57 */
     58inline int isFloat32lt(float32 a, float32 b)
     59{
     60        if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
     61                return 0;
     62        };
     63        a.parts.sign^=a.parts.sign;
     64        b.parts.sign^=b.parts.sign;
     65        return (a.binary<b.binary);
     66                       
     67}
     68
     69
  • softfloat/generic/softfloat.c

    rb5440cf r7e557805  
    8484/* Comparison functions */
    8585
     86/* a<b .. -1
     87 * a=b ..  0
     88 * a>b ..  1
     89 * */
     90
     91int __cmpsf2(double a, double b)
     92{
     93        float32 fa,fb;
     94        fa.f=a;
     95        fb.f=b;
     96        if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) {
     97                return 1; /* no special constant for unordered - maybe signaled? */
     98        };
     99
     100       
     101        if (isFloat32eq(fa,fb)) {
     102                return 0;
     103        };
     104       
     105        if (isFloat32lt(fa,fb)) {
     106                return -1;
     107                };
     108        return 1;
     109}
     110
     111int __unordsf2(float a, float b)
     112{
     113        float32 fa,fb;
     114        fa.f=a;
     115        fb.f=b;
     116        return ((isFloat32NaN(fa))||(isFloat32NaN(fb)));
     117};
     118
     119/**
     120 * @return zero, if neither argument is a NaN and are equal
     121 * */
     122int __eqsf2(float a, float b)
     123{
     124        float32 fa,fb;
     125        fa.f=a;
     126        fb.f=b;
     127        if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) {
     128                /* TODO: sigNaNs*/
     129                return 1;
     130                };
     131        return isFloat32eq(fa,fb)-1;
     132};
     133
     134/* strange behavior, but it was in gcc documentation */
     135int __nesf2(float a, float b)
     136{
     137        return __eqsf2(a,b);
     138};
    86139/* Other functions */
    87140
  • softfloat/include/sftypes.h

    rb5440cf r7e557805  
    3333typedef union {
    3434        float f;
     35        __u32 binary;
     36
    3537        struct  {
    3638                #ifdef __BIG_ENDIAN__
     
    5052typedef union {
    5153        double d;
     54        __u64 binary;
     55       
    5256        struct  {
    5357                #ifdef __BIG_ENDIAN__
Note: See TracChangeset for help on using the changeset viewer.