-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexcel_out-ieee_754-generic_double_precision.ads
131 lines (127 loc) · 4.85 KB
/
excel_out-ieee_754-generic_double_precision.ads
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- IEEE_754.Generic_Double_Precision Luebeck --
-- Interface Summer, 2008 --
-- --
-- Last revision : 09:27 06 Nov 2016 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
generic
type Number is digits <>;
package Excel_Out.IEEE_754.Generic_Double_Precision is
use Interfaces;
--
-- Float_64 -- 64-bit double-precision IEEE 754 float. The memory layout
-- is big endian, i.e. the byte containing the number's sign
-- and the most significant bits of the exponent is the first array
-- element. The byte containing the least significant bits of the
-- mantissa is the last array element.
--
type Float_64 is array (1 .. 8) of Byte;
Positive_Infinity : constant Float_64;
Positive_Zero : constant Float_64;
Negative_Infinity : constant Float_64;
Negative_Zero : constant Float_64;
--
-- From_IEEE -- Conversion from 32-bit single precision IEEE 754 float
--
-- Value - The argument
--
-- Returns :
--
-- The corresponding floating-point number
--
-- Exceptions :
--
-- Not_A_Number_Error - Not a number
-- Positive_Overflow_Error - Positive infinity or too big positive
-- Negative_Overflow_Error - Negative infinity or too big negative
--
function From_IEEE (Value : Float_64) return Number;
--
-- Is_NaN -- NaN test
--
-- Value - The argument
--
-- Returns :
--
-- True if Value is an IEEE NaN
--
function Is_NaN (Value : Float_64) return Boolean;
--
-- Is_Negative -- IEEE sign test
--
-- Value - The argument
--
-- Returns :
--
-- True if Value has an IEEE sign
--
function Is_Negative (Value : Float_64) return Boolean;
--
-- Is_Real -- Value test
--
-- Value - The argument
--
-- This function tests if Value represents a real number. Infinities and
-- NaN are not numbers. Both zeros are considered numbers.
--
-- Returns :
--
-- True if Value represents a real number
--
function Is_Real (Value : Float_64) return Boolean;
--
-- Normalize -- Split number into integer mantissa and binary exponent
--
-- Value - The argument
-- Mantissa - The mantissa
-- Exponent - The binary exponent
--
procedure Normalize
(Value : Number;
Mantissa : out Unsigned_64;
Exponent : out Integer
);
--
-- To_IEEE -- Conversion to 32-bit single precision IEEE 754 float
--
-- Value - The argument
--
-- The value to big for normalized representation results in the
-- corresponding IEEE infinities. Too small values are represented as
-- IEEE zero.
--
-- Returns :
--
-- The corresponding IEEE 754 representation
--
function To_IEEE (Value : Number) return Float_64;
private
pragma Inline (Is_NaN);
pragma Inline (Is_Negative);
pragma Inline (Is_Real);
pragma Inline (Normalize);
Positive_Infinity : constant Float_64 := (16#7F#, 16#F0#, others => 0);
Positive_Zero : constant Float_64 := (others => 0);
Negative_Infinity : constant Float_64 := (16#FF#, 16#F8#, others => 0);
Negative_Zero : constant Float_64 := (16#80#, others => 0);
end Excel_Out.IEEE_754.Generic_Double_Precision;