Rev 653 | Rev 688 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 653 | Rev 660 | ||
---|---|---|---|
Line 47... | Line 47... | ||
47 | /** |
47 | /** |
48 | * @return 1, if both floats are equal - but NaNs are not recognized |
48 | * @return 1, if both floats are equal - but NaNs are not recognized |
49 | */ |
49 | */ |
50 | inline int isFloat32eq(float32 a, float32 b) |
50 | inline int isFloat32eq(float32 a, float32 b) |
51 | { |
51 | { |
52 | return ((a==b)||(((a.binary| b.binary)&0x7FFFFFFF)==0)); /* a equals to b or both are zeros (with any sign) */ |
52 | return ((a.binary==b.binary)||(((a.binary| b.binary)&0x7FFFFFFF)==0)); /* a equals to b or both are zeros (with any sign) */ |
53 | } |
53 | } |
54 | 54 | ||
55 | /** |
55 | /** |
56 | * @return 1, if a<b - but NaNs are not recognized |
56 | * @return 1, if a<b - but NaNs are not recognized |
57 | */ |
57 | */ |
58 | inline int isFloat32lt(float32 a, float32 b) |
58 | inline int isFloat32lt(float32 a, float32 b) |
59 | { |
59 | { |
60 | if (((a.binary| b.binary)&0x7FFFFFFF)==0) { |
60 | if (((a.binary| b.binary)&0x7FFFFFFF)==0) { |
61 | return 0; |
61 | return 0; /* +- zeroes */ |
62 | }; |
62 | }; |
- | 63 | ||
- | 64 | if ((a.parts.sign)&&(b.parts.sign)) { |
|
- | 65 | /*if both are negative, smaller is that with greater binary value*/ |
|
- | 66 | return (a.binary>b.binary); |
|
- | 67 | }; |
|
- | 68 | ||
- | 69 | /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/ |
|
63 | a.parts.sign^=a.parts.sign; |
70 | a.parts.sign=!a.parts.sign; |
64 | b.parts.sign^=b.parts.sign; |
71 | b.parts.sign=!b.parts.sign; |
65 | return (a.binary<b.binary); |
72 | return (a.binary<b.binary); |
66 | 73 | ||
67 | } |
74 | } |
68 | 75 | ||
69 | /** |
76 | /** |
70 | * @return 1, if a>b - but NaNs are not recognized |
77 | * @return 1, if a>b - but NaNs are not recognized |
71 | */ |
78 | */ |
72 | inline int isFloat32gt(float32 a, float32 b) |
79 | inline int isFloat32gt(float32 a, float32 b) |
73 | { |
80 | { |
74 | if (((a.binary| b.binary)&0x7FFFFFFF)==0) { |
81 | if (((a.binary| b.binary)&0x7FFFFFFF)==0) { |
75 | return 0; |
82 | return 0; /* zeroes are equal with any sign */ |
76 | }; |
83 | }; |
- | 84 | ||
- | 85 | if ((a.parts.sign)&&(b.parts.sign)) { |
|
- | 86 | /*if both are negative, greater is that with smaller binary value*/ |
|
- | 87 | return (a.binary<b.binary); |
|
- | 88 | }; |
|
- | 89 | ||
- | 90 | /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/ |
|
77 | a.parts.sign^=a.parts.sign; |
91 | a.parts.sign=!a.parts.sign; |
78 | b.parts.sign^=b.parts.sign; |
92 | b.parts.sign=!b.parts.sign; |
79 | return (a.binary>b.binary); |
93 | return (a.binary>b.binary); |
80 | 94 | ||
81 | } |
95 | } |
82 | 96 | ||
83 | 97 |