Changeset e649dfa in mainline


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

Comparison function for float type added.

Location:
softfloat
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified softfloat/generic/comparison.c

    r7e557805 re649dfa  
    5454
    5555/**
    56  * @return 1, if a>b - but NaNs are not recognized
     56 * @return 1, if a<b - but NaNs are not recognized
    5757 */
    5858inline int isFloat32lt(float32 a, float32 b)
     
    6767}
    6868
     69/**
     70 * @return 1, if a>b - but NaNs are not recognized
     71 */
     72inline int isFloat32gt(float32 a, float32 b)
     73{
     74        if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
     75                return 0;
     76        };
     77        a.parts.sign^=a.parts.sign;
     78        b.parts.sign^=b.parts.sign;
     79        return (a.binary>b.binary);
     80                       
     81}
    6982
     83
  • TabularUnified softfloat/generic/softfloat.c

    r7e557805 re649dfa  
    137137        return __eqsf2(a,b);
    138138};
     139
     140/* return value >= 0 if a>=b and neither is NaN */
     141int __gesf2(float a, float b)
     142{
     143        float32 fa,fb;
     144        fa.f=a;
     145        fb.f=b;
     146        if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) {
     147                /* TODO: sigNaNs*/
     148                return 1;
     149                };
     150       
     151        if (isFloat32eq(fa,fb)) {
     152                return 0;
     153        };
     154       
     155        if (isFloat32gt(fa,fb)) {
     156                return 1;
     157                };
     158       
     159        return -1;
     160}
     161
     162/** Return negative value, if a<b and neither is NaN*/
     163int __ltsf2(float a, float b)
     164{
     165        float32 fa,fb;
     166        fa.f=a;
     167        fb.f=b;
     168        if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) {
     169                /* TODO: sigNaNs*/
     170                return 1;
     171                };
     172        if (isFloat32lt(fa, fb)) {
     173                return -1;
     174                };
     175        return 0;
     176}
     177
     178/* return value <= 0 if a<=b and neither is NaN */
     179int __lesf2(float a, float b)
     180{
     181        float32 fa,fb;
     182        fa.f=a;
     183        fb.f=b;
     184        if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) {
     185                /* TODO: sigNaNs*/
     186                return 1;
     187                };
     188       
     189        if (isFloat32eq(fa,fb)) {
     190                return 0;
     191        };
     192       
     193        if (isFloat32lt(fa,fb)) {
     194                return -1;
     195                };
     196       
     197        return 1;
     198}
     199
     200/** Return positive value, if a>b and neither is NaN*/
     201int __ltsf2(float a, float b)
     202{
     203        float32 fa,fb;
     204        fa.f=a;
     205        fb.f=b;
     206        if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) {
     207                /* TODO: sigNaNs*/
     208                return 1;
     209                };
     210        if (isFloat32gt(fa, fb)) {
     211                return 1;
     212                };
     213        return 0;
     214}
     215
    139216/* Other functions */
    140217
  • TabularUnified softfloat/include/comparison.h

    r7e557805 re649dfa  
    3333inline int isFloat32SigNaN(float32 f);
    3434
     35inline int isFloat32Infinity(float32 f)
     36
     37inline int isFloat32eq(float32 a, float32 b);
     38inline int isFloat32lt(float32 a, float32 b);
     39inline int isFloat32gt(float32 a, float32 b);
     40
    3541#endif
    3642
Note: See TracChangeset for help on using the changeset viewer.