Ignore:
Timestamp:
2011-05-06T14:21:25Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7b90778d, b5e68c8
Parents:
042fbe0
Message:

softfloat: slightly improve coding style (no change in functionality)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/softfloat/generic/comparison.c

    r042fbe0 r750636a  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<comparison.h>
     35#include <sftypes.h>
     36#include <comparison.h>
    3737
    38 inline int isFloat32NaN(float32 f)
    39 {       /* NaN : exp = 0xff and nonzero fraction */
    40         return ((f.parts.exp==0xFF)&&(f.parts.fraction));
     38/* NaN : exp = 0xff and nonzero fraction */
     39int isFloat32NaN(float32 f)
     40{
     41        return ((f.parts.exp == 0xFF) && (f.parts.fraction));
    4142}
    4243
    43 inline int isFloat64NaN(float64 d)
    44 {       /* NaN : exp = 0x7ff and nonzero fraction */
    45         return ((d.parts.exp==0x7FF)&&(d.parts.fraction));
     44/* NaN : exp = 0x7ff and nonzero fraction */
     45int isFloat64NaN(float64 d)
     46{
     47        return ((d.parts.exp == 0x7FF) && (d.parts.fraction));
    4648}
    4749
    48 inline int isFloat32SigNaN(float32 f)
    49 {       /* SigNaN : exp = 0xff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
    50         return ((f.parts.exp==0xFF)&&(f.parts.fraction<0x400000)&&(f.parts.fraction));
     50/* SigNaN : exp = 0xff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
     51int isFloat32SigNaN(float32 f)
     52{
     53        return ((f.parts.exp == 0xFF) && (f.parts.fraction < 0x400000) && (f.parts.fraction));
    5154}
    5255
    53 inline int isFloat64SigNaN(float64 d)
    54 {       /* SigNaN : exp = 0x7ff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
    55         return ((d.parts.exp==0x7FF)&&(d.parts.fraction)&&(d.parts.fraction<0x8000000000000ll));
     56/* SigNaN : exp = 0x7ff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
     57int isFloat64SigNaN(float64 d)
     58{
     59        return ((d.parts.exp == 0x7FF) && (d.parts.fraction) && (d.parts.fraction < 0x8000000000000ll));
    5660}
    5761
    58 inline int isFloat32Infinity(float32 f)
     62int isFloat32Infinity(float32 f)
    5963{
    60         return ((f.parts.exp==0xFF)&&(f.parts.fraction==0x0));
     64        return ((f.parts.exp == 0xFF) && (f.parts.fraction == 0x0));
    6165}
    6266
    63 inline int isFloat64Infinity(float64 d)
     67int isFloat64Infinity(float64 d)
    6468{
    65         return ((d.parts.exp==0x7FF)&&(d.parts.fraction==0x0));
     69        return ((d.parts.exp == 0x7FF) && (d.parts.fraction == 0x0));
    6670}
    6771
    68 inline int isFloat32Zero(float32 f)
     72int isFloat32Zero(float32 f)
    6973{
    7074        return (((f.binary) & 0x7FFFFFFF) == 0);
    7175}
    7276
    73 inline int isFloat64Zero(float64 d)
     77int isFloat64Zero(float64 d)
    7478{
    7579        return (((d.binary) & 0x7FFFFFFFFFFFFFFFll) == 0);
     
    7781
    7882/**
    79  * @return 1, if both floats are equal - but NaNs are not recognized
     83 * @return 1 if both floats are equal - but NaNs are not recognized
    8084 */
    81 inline int isFloat32eq(float32 a, float32 b)
     85int isFloat32eq(float32 a, float32 b)
    8286{
    83         return ((a.binary==b.binary)||(((a.binary| b.binary)&0x7FFFFFFF)==0)); /* a equals to b or both are zeros (with any sign) */
     87        /* a equals to b or both are zeros (with any sign) */
     88        return ((a.binary==b.binary) || (((a.binary | b.binary) & 0x7FFFFFFF) == 0));
    8489}
    8590
    8691/**
    87  * @return 1, if a<b - but NaNs are not recognized
     92 * @return 1 if a < b - but NaNs are not recognized
    8893 */
    89 inline int isFloat32lt(float32 a, float32 b)
     94int isFloat32lt(float32 a, float32 b)
    9095{
    91         if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
     96        if (((a.binary | b.binary) & 0x7FFFFFFF) == 0)
    9297                return 0; /* +- zeroes */
    93         };
    9498       
    95         if ((a.parts.sign)&&(b.parts.sign)) {
    96                 /*if both are negative, smaller is that with greater binary value*/
    97                 return (a.binary>b.binary);
    98                 };
     99        if ((a.parts.sign) && (b.parts.sign))
     100                /* if both are negative, smaller is that with greater binary value */
     101                return (a.binary > b.binary);
    99102       
    100         /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/
    101         a.parts.sign=!a.parts.sign;
    102         b.parts.sign=!b.parts.sign;
    103         return (a.binary<b.binary);
    104                        
     103        /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison) */
     104        a.parts.sign = !a.parts.sign;
     105        b.parts.sign = !b.parts.sign;
     106        return (a.binary < b.binary);
    105107}
    106108
    107109/**
    108  * @return 1, if a>b - but NaNs are not recognized
     110 * @return 1 if a > b - but NaNs are not recognized
    109111 */
    110 inline int isFloat32gt(float32 a, float32 b)
     112int isFloat32gt(float32 a, float32 b)
    111113{
    112         if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
     114        if (((a.binary | b.binary) & 0x7FFFFFFF) == 0)
    113115                return 0; /* zeroes are equal with any sign */
    114         };
    115116       
    116         if ((a.parts.sign)&&(b.parts.sign)) {
    117                 /*if both are negative, greater is that with smaller binary value*/
    118                 return (a.binary<b.binary);
    119                 };
     117        if ((a.parts.sign) && (b.parts.sign))
     118                /* if both are negative, greater is that with smaller binary value */
     119                return (a.binary < b.binary);
    120120       
    121         /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/
    122         a.parts.sign=!a.parts.sign;
    123         b.parts.sign=!b.parts.sign;
    124         return (a.binary>b.binary);
    125                        
     121        /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison) */
     122        a.parts.sign = !a.parts.sign;
     123        b.parts.sign = !b.parts.sign;
     124        return (a.binary > b.binary);
    126125}
    127126
Note: See TracChangeset for help on using the changeset viewer.