VirtualBox

source: vbox/trunk/src/libs/softfloat-3e/source/s_compareNonnormExtF80M.c@ 97642

Last change on this file since 97642 was 94480, checked in by vboxsync, 3 years ago

libs/softfloat-3e: Copied from vendor branch (SoftFloat-3e.zip, md5: 7dac954ea4aed0697cbfee800ba4f492). bugref:9898

  • Property svn:eol-style set to native
File size: 4.2 KB
Line 
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat_types.h"
41
42int
43 softfloat_compareNonnormExtF80M(
44 const struct extFloat80M *aSPtr, const struct extFloat80M *bSPtr )
45{
46 uint_fast16_t uiA64, uiB64;
47 uint64_t sigA;
48 bool signB;
49 uint64_t sigB;
50 int32_t expA, expB;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uiA64 = aSPtr->signExp;
55 uiB64 = bSPtr->signExp;
56 sigA = aSPtr->signif;
57 signB = signExtF80UI64( uiB64 );
58 sigB = bSPtr->signif;
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 if ( (uiA64 ^ uiB64) & 0x8000 ) {
62 if ( ! (sigA | sigB) ) return 0;
63 goto resultFromSignB;
64 }
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expA = expExtF80UI64( uiA64 );
68 expB = expExtF80UI64( uiB64 );
69 if ( expA == 0x7FFF ) {
70 if (expB == 0x7FFF) return 0;
71 signB = ! signB;
72 goto resultFromSignB;
73 }
74 if ( expB == 0x7FFF ) {
75 goto resultFromSignB;
76 }
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( ! expA ) expA = 1;
80 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
81 if ( sigA ) {
82 expA += softfloat_normExtF80SigM( &sigA );
83 } else {
84 expA = -128;
85 }
86 }
87 if ( ! expB ) expB = 1;
88 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
89 if ( sigB ) {
90 expB += softfloat_normExtF80SigM( &sigB );
91 } else {
92 expB = -128;
93 }
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 if ( signB ) {
98 if ( expA < expB ) return 1;
99 if ( (expB < expA) || (sigB < sigA) ) return -1;
100 } else {
101 if ( expB < expA ) return 1;
102 if ( (expA < expB) || (sigA < sigB) ) return -1;
103 }
104 return (sigA != sigB);
105 /*------------------------------------------------------------------------
106 *------------------------------------------------------------------------*/
107 resultFromSignB:
108 return signB ? 1 : -1;
109
110}
111
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette