PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/src/lib/numeric/real_128.e

http://github.com/tybor/Liberty
Specman e | 82 lines | 45 code | 14 blank | 23 comment | 1 complexity | de5b9a4c30d7eef6b6b3c617ee311818 MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4expanded class REAL_128
 5
 6insert
 7   REAL_GENERAL
 8
 9feature {ANY} -- Conversions:
10   force_to_real_32: REAL_32
11      external "built_in"
12      end
13
14   force_to_real_64: REAL_64
15      external "built_in"
16      end
17
18   force_to_integer_64: INTEGER_64
19      external "built_in"
20      end
21
22   force_to_integer_32: INTEGER_32
23      external "built_in"
24      end
25
26   force_to_integer_16: INTEGER_16
27      external "built_in"
28      end
29
30feature {ANY}
31   zero: REAL_32 0.0
32
33   one: REAL_32 1.0
34
35   infix "~=" (other: like Current): BOOLEAN
36      do
37         Result := (Current - other).abs * ({REAL_128 2.0} ^ (mantissa_bits - precision)) <= Current.abs
38      end
39
40   hash_code: INTEGER
41      do
42         Result := force_to_integer_32
43         if Result < 0 then
44            Result := -(Result + 1)
45         end
46      end
47
48   mantissa_bits: INTEGER_8 112
49
50   exponent_bits: INTEGER_8 15
51
52feature {}
53   sprintf (buffer: NATIVE_ARRAY[CHARACTER]; mode: CHARACTER; f: INTEGER; value: REAL_128)
54      external "plug_in"
55      alias "{
56         location: "${sys}/runtime"
57         module_name: "basic_sprintf"
58         feature_name: "sprintf_real_extended"
59         }"
60      end
61
62end -- class REAL_128
63--
64-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
65--
66-- Permission is hereby granted, free of charge, to any person obtaining a copy
67-- of this software and associated documentation files (the "Software"), to deal
68-- in the Software without restriction, including without limitation the rights
69-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
70-- copies of the Software, and to permit persons to whom the Software is
71-- furnished to do so, subject to the following conditions:
72--
73-- The above copyright notice and this permission notice shall be included in
74-- all copies or substantial portions of the Software.
75--
76-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
77-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
78-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
79-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
80-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
81-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
82-- THE SOFTWARE.