Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5e3eda4

Browse files
committed
> Here is an extension of the regression test suite for Digital Unix
(Alpha).>> Andreas Kardos
1 parent27b3f7c commit5e3eda4

File tree

1 file changed

+246
-0
lines changed

1 file changed

+246
-0
lines changed
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
--
2+
-- FLOAT8
3+
--
4+
CREATE TABLE FLOAT8_TBL(f1 float8);
5+
INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
6+
INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30');
7+
INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
8+
INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
9+
INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
10+
SELECT '' AS five, FLOAT8_TBL.*;
11+
five | f1
12+
------+----------------------
13+
| 0
14+
| 1004.3
15+
| -34.84
16+
| 1.2345678901234e+200
17+
| 1.2345678901234e-200
18+
(5 rows)
19+
20+
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3';
21+
four | f1
22+
------+----------------------
23+
| 0
24+
| -34.84
25+
| 1.2345678901234e+200
26+
| 1.2345678901234e-200
27+
(4 rows)
28+
29+
SELECT '' AS one, f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3';
30+
one | f1
31+
-----+--------
32+
| 1004.3
33+
(1 row)
34+
35+
SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1;
36+
three | f1
37+
-------+----------------------
38+
| 0
39+
| -34.84
40+
| 1.2345678901234e-200
41+
(3 rows)
42+
43+
SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3';
44+
three | f1
45+
-------+----------------------
46+
| 0
47+
| -34.84
48+
| 1.2345678901234e-200
49+
(3 rows)
50+
51+
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1;
52+
four | f1
53+
------+----------------------
54+
| 0
55+
| 1004.3
56+
| -34.84
57+
| 1.2345678901234e-200
58+
(4 rows)
59+
60+
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3';
61+
four | f1
62+
------+----------------------
63+
| 0
64+
| 1004.3
65+
| -34.84
66+
| 1.2345678901234e-200
67+
(4 rows)
68+
69+
SELECT '' AS three, f.f1, f.f1 * '-10' AS x
70+
FROM FLOAT8_TBL f
71+
WHERE f.f1 > '0.0';
72+
three | f1 | x
73+
-------+----------------------+-----------------------
74+
| 1004.3 | -10043
75+
| 1.2345678901234e+200 | -1.2345678901234e+201
76+
| 1.2345678901234e-200 | -1.2345678901234e-199
77+
(3 rows)
78+
79+
SELECT '' AS three, f.f1, f.f1 + '-10' AS x
80+
FROM FLOAT8_TBL f
81+
WHERE f.f1 > '0.0';
82+
three | f1 | x
83+
-------+----------------------+----------------------
84+
| 1004.3 | 994.3
85+
| 1.2345678901234e+200 | 1.2345678901234e+200
86+
| 1.2345678901234e-200 | -10
87+
(3 rows)
88+
89+
SELECT '' AS three, f.f1, f.f1 / '-10' AS x
90+
FROM FLOAT8_TBL f
91+
WHERE f.f1 > '0.0';
92+
three | f1 | x
93+
-------+----------------------+-----------------------
94+
| 1004.3 | -100.43
95+
| 1.2345678901234e+200 | -1.2345678901234e+199
96+
| 1.2345678901234e-200 | -1.2345678901234e-201
97+
(3 rows)
98+
99+
SELECT '' AS three, f.f1, f.f1 - '-10' AS x
100+
FROM FLOAT8_TBL f
101+
WHERE f.f1 > '0.0';
102+
three | f1 | x
103+
-------+----------------------+----------------------
104+
| 1004.3 | 1014.3
105+
| 1.2345678901234e+200 | 1.2345678901234e+200
106+
| 1.2345678901234e-200 | 10
107+
(3 rows)
108+
109+
SELECT '' AS one, f.f1 ^ '2.0' AS square_f1
110+
FROM FLOAT8_TBL f where f.f1 = '1004.3';
111+
one | square_f1
112+
-----+------------
113+
| 1008618.49
114+
(1 row)
115+
116+
-- absolute value
117+
SELECT '' AS five, f.f1, @f.f1 AS abs_f1
118+
FROM FLOAT8_TBL f;
119+
five | f1 | abs_f1
120+
------+----------------------+----------------------
121+
| 0 | 0
122+
| 1004.3 | 1004.3
123+
| -34.84 | 34.84
124+
| 1.2345678901234e+200 | 1.2345678901234e+200
125+
| 1.2345678901234e-200 | 1.2345678901234e-200
126+
(5 rows)
127+
128+
-- truncate
129+
SELECT '' AS five, f.f1, %f.f1 AS trunc_f1
130+
FROM FLOAT8_TBL f;
131+
five | f1 | trunc_f1
132+
------+----------------------+----------------------
133+
| 0 | 0
134+
| 1004.3 | 1004
135+
| -34.84 | -34
136+
| 1.2345678901234e+200 | 1.2345678901234e+200
137+
| 1.2345678901234e-200 | 0
138+
(5 rows)
139+
140+
-- round
141+
SELECT '' AS five, f.f1, f.f1 % AS round_f1
142+
FROM FLOAT8_TBL f;
143+
five | f1 | round_f1
144+
------+----------------------+----------------------
145+
| 0 | 0
146+
| 1004.3 | 1004
147+
| -34.84 | -35
148+
| 1.2345678901234e+200 | 1.2345678901234e+200
149+
| 1.2345678901234e-200 | 0
150+
(5 rows)
151+
152+
-- square root
153+
SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
154+
FROM FLOAT8_TBL f
155+
WHERE f.f1 > '0.0';
156+
three | f1 | sqrt_f1
157+
-------+----------------------+-----------------------
158+
| 1004.3 | 31.6906926399535
159+
| 1.2345678901234e+200 | 1.11111110611109e+100
160+
| 1.2345678901234e-200 | 1.11111110611109e-100
161+
(3 rows)
162+
163+
-- take exp of ln(f.f1)
164+
SELECT '' AS three, f.f1, : ( ; f.f1) AS exp_ln_f1
165+
FROM FLOAT8_TBL f
166+
WHERE f.f1 > '0.0';
167+
three | f1 | exp_ln_f1
168+
-------+----------------------+-----------------------
169+
| 1004.3 | 1004.3
170+
| 1.2345678901234e+200 | 1.23456789012338e+200
171+
| 1.2345678901234e-200 | 1.23456789012339e-200
172+
(3 rows)
173+
174+
-- cube root
175+
SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
176+
five | f1 | cbrt_f1
177+
------+----------------------+----------------------
178+
| 0 | 0
179+
| 1004.3 | 10.014312837827
180+
| -34.84 | -3.26607421344208
181+
| 1.2345678901234e+200 | 4.97933859234765e+66
182+
| 1.2345678901234e-200 | 2.3112042409018e-67
183+
(5 rows)
184+
185+
SELECT '' AS five, FLOAT8_TBL.*;
186+
five | f1
187+
------+----------------------
188+
| 0
189+
| 1004.3
190+
| -34.84
191+
| 1.2345678901234e+200
192+
| 1.2345678901234e-200
193+
(5 rows)
194+
195+
UPDATE FLOAT8_TBL
196+
SET f1 = FLOAT8_TBL.f1 * '-1'
197+
WHERE FLOAT8_TBL.f1 > '0.0';
198+
SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
199+
ERROR: floating point exception! The last floating point operation either exceeded legal ranges or was a divide by zero
200+
SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
201+
ERROR: pow() result is out of range
202+
SELECT '' AS bad, (; (f.f1)) from FLOAT8_TBL f where f.f1 = '0.0' ;
203+
ERROR: can't take log of zero
204+
SELECT '' AS bad, (; (f.f1)) from FLOAT8_TBL f where f.f1 < '0.0' ;
205+
ERROR: can't take log of a negative number
206+
SELECT '' AS bad, : (f.f1) from FLOAT8_TBL f;
207+
ERROR: exp() result is out of range
208+
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
209+
ERROR: float8div: divide by zero error
210+
SELECT '' AS five, FLOAT8_TBL.*;
211+
five | f1
212+
------+-----------------------
213+
| 0
214+
| -34.84
215+
| -1004.3
216+
| -1.2345678901234e+200
217+
| -1.2345678901234e-200
218+
(5 rows)
219+
220+
-- test for over and under flow
221+
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
222+
ERROR: Input '10e400' is out of range for float8
223+
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
224+
ERROR: Input '-10e400' is out of range for float8
225+
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
226+
ERROR: Input '10e-400' is out of range for float8
227+
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
228+
ERROR: Input '-10e-400' is out of range for float8
229+
-- maintain external table consistency across platforms
230+
-- delete all values and reinsert well-behaved ones
231+
DELETE FROM FLOAT8_TBL;
232+
INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
233+
INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
234+
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
235+
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
236+
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
237+
SELECT '' AS five, FLOAT8_TBL.*;
238+
five | f1
239+
------+-----------------------
240+
| 0
241+
| -34.84
242+
| -1004.3
243+
| -1.2345678901234e+200
244+
| -1.2345678901234e-200
245+
(5 rows)
246+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp