OLD | NEW |
1 // Inferno utils/cc/lexbody | 1 // Inferno utils/cc/lexbody |
2 // http://code.google.com/p/inferno-os/source/browse/utils/cc/lexbody | 2 // http://code.google.com/p/inferno-os/source/browse/utils/cc/lexbody |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 for(i=0; i<n; i++) | 738 for(i=0; i<n; i++) |
739 print("%s:%ld ", a[i].name, (long)(l-a[i].line+a[i].offset+1)); | 739 print("%s:%ld ", a[i].name, (long)(l-a[i].line+a[i].offset+1)); |
740 } | 740 } |
741 | 741 |
742 void | 742 void |
743 ieeedtod(Ieee *ieee, double native) | 743 ieeedtod(Ieee *ieee, double native) |
744 { | 744 { |
745 double fr, ho, f; | 745 double fr, ho, f; |
746 int exp; | 746 int exp; |
747 | 747 |
748 » if(native < 0) { | 748 » if(signbit(native)) { |
749 ieeedtod(ieee, -native); | 749 ieeedtod(ieee, -native); |
750 ieee->h |= 0x80000000L; | 750 ieee->h |= 0x80000000L; |
751 return; | 751 return; |
752 } | 752 } |
753 if(native == 0) { | 753 if(native == 0) { |
754 ieee->l = 0; | 754 ieee->l = 0; |
755 ieee->h = 0; | 755 ieee->h = 0; |
756 return; | 756 return; |
757 } | 757 } |
758 fr = frexp(native, &exp); | 758 fr = frexp(native, &exp); |
759 f = 2097152L; /* shouldnt use fp constants here */ | 759 f = 2097152L; /* shouldnt use fp constants here */ |
760 fr = modf(fr*f, &ho); | 760 fr = modf(fr*f, &ho); |
761 ieee->h = ho; | 761 ieee->h = ho; |
762 ieee->h &= 0xfffffL; | 762 ieee->h &= 0xfffffL; |
763 ieee->h |= (exp+1022L) << 20; | 763 ieee->h |= (exp+1022L) << 20; |
764 f = 65536L; | 764 f = 65536L; |
765 fr = modf(fr*f, &ho); | 765 fr = modf(fr*f, &ho); |
766 ieee->l = ho; | 766 ieee->l = ho; |
767 ieee->l <<= 16; | 767 ieee->l <<= 16; |
768 ieee->l |= (int32)(fr*f); | 768 ieee->l |= (int32)(fr*f); |
769 } | 769 } |
OLD | NEW |