]> granicus.if.org Git - postgresql/blob - src/test/regress/expected/float8-small-is-zero_1.out
Update alternative output regression files for new float8 test of power().
[postgresql] / src / test / regress / expected / float8-small-is-zero_1.out
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 -- test for underflow and overflow handling
11 SELECT '10e400'::float8;
12 ERROR:  "10e400" is out of range for type double precision
13 SELECT '-10e400'::float8;
14 ERROR:  "-10e400" is out of range for type double precision
15 SELECT '10e-400'::float8;
16  float8 
17 --------
18      0
19 (1 row)
20
21 SELECT '-10e-400'::float8;
22  float8 
23 --------
24      0
25 (1 row)
26
27 -- bad input
28 INSERT INTO FLOAT8_TBL(f1) VALUES ('');
29 ERROR:  invalid input syntax for type double precision: ""
30 INSERT INTO FLOAT8_TBL(f1) VALUES ('     ');
31 ERROR:  invalid input syntax for type double precision: "     "
32 INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
33 ERROR:  invalid input syntax for type double precision: "xyz"
34 INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0');
35 ERROR:  invalid input syntax for type double precision: "5.0.0"
36 INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0');
37 ERROR:  invalid input syntax for type double precision: "5 . 0"
38 INSERT INTO FLOAT8_TBL(f1) VALUES ('5.   0');
39 ERROR:  invalid input syntax for type double precision: "5.   0"
40 INSERT INTO FLOAT8_TBL(f1) VALUES ('    - 3');
41 ERROR:  invalid input syntax for type double precision: "    - 3"
42 INSERT INTO FLOAT8_TBL(f1) VALUES ('123           5');
43 ERROR:  invalid input syntax for type double precision: "123           5"
44 -- special inputs
45 SELECT 'NaN'::float8;
46  float8 
47 --------
48     NaN
49 (1 row)
50
51 SELECT 'nan'::float8;
52  float8 
53 --------
54     NaN
55 (1 row)
56
57 SELECT '   NAN  '::float8;
58  float8 
59 --------
60     NaN
61 (1 row)
62
63 SELECT 'infinity'::float8;
64   float8  
65 ----------
66  Infinity
67 (1 row)
68
69 SELECT '          -INFINiTY   '::float8;
70   float8   
71 -----------
72  -Infinity
73 (1 row)
74
75 -- bad special inputs
76 SELECT 'N A N'::float8;
77 ERROR:  invalid input syntax for type double precision: "N A N"
78 SELECT 'NaN x'::float8;
79 ERROR:  invalid input syntax for type double precision: "NaN x"
80 SELECT ' INFINITY    x'::float8;
81 ERROR:  invalid input syntax for type double precision: " INFINITY    x"
82 SELECT 'Infinity'::float8 + 100.0;
83  ?column? 
84 ----------
85  Infinity
86 (1 row)
87
88 SELECT 'Infinity'::float8 / 'Infinity'::float8;
89  ?column? 
90 ----------
91       NaN
92 (1 row)
93
94 SELECT 'nan'::float8 / 'nan'::float8;
95  ?column? 
96 ----------
97       NaN
98 (1 row)
99
100 SELECT '' AS five, * FROM FLOAT8_TBL;
101  five |          f1          
102 ------+----------------------
103       |                    0
104       |               1004.3
105       |               -34.84
106       | 1.2345678901234e+200
107       | 1.2345678901234e-200
108 (5 rows)
109
110 SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3';
111  four |          f1          
112 ------+----------------------
113       |                    0
114       |               -34.84
115       | 1.2345678901234e+200
116       | 1.2345678901234e-200
117 (4 rows)
118
119 SELECT '' AS one, f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3';
120  one |   f1   
121 -----+--------
122      | 1004.3
123 (1 row)
124
125 SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1;
126  three |          f1          
127 -------+----------------------
128        |                    0
129        |               -34.84
130        | 1.2345678901234e-200
131 (3 rows)
132
133 SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE  f.f1 < '1004.3';
134  three |          f1          
135 -------+----------------------
136        |                    0
137        |               -34.84
138        | 1.2345678901234e-200
139 (3 rows)
140
141 SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1;
142  four |          f1          
143 ------+----------------------
144       |                    0
145       |               1004.3
146       |               -34.84
147       | 1.2345678901234e-200
148 (4 rows)
149
150 SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE  f.f1 <= '1004.3';
151  four |          f1          
152 ------+----------------------
153       |                    0
154       |               1004.3
155       |               -34.84
156       | 1.2345678901234e-200
157 (4 rows)
158
159 SELECT '' AS three, f.f1, f.f1 * '-10' AS x 
160    FROM FLOAT8_TBL f
161    WHERE f.f1 > '0.0';
162  three |          f1          |           x           
163 -------+----------------------+-----------------------
164        |               1004.3 |                -10043
165        | 1.2345678901234e+200 | -1.2345678901234e+201
166        | 1.2345678901234e-200 | -1.2345678901234e-199
167 (3 rows)
168
169 SELECT '' AS three, f.f1, f.f1 + '-10' AS x
170    FROM FLOAT8_TBL f
171    WHERE f.f1 > '0.0';
172  three |          f1          |          x           
173 -------+----------------------+----------------------
174        |               1004.3 |                994.3
175        | 1.2345678901234e+200 | 1.2345678901234e+200
176        | 1.2345678901234e-200 |                  -10
177 (3 rows)
178
179 SELECT '' AS three, f.f1, f.f1 / '-10' AS x
180    FROM FLOAT8_TBL f
181    WHERE f.f1 > '0.0';
182  three |          f1          |           x           
183 -------+----------------------+-----------------------
184        |               1004.3 |               -100.43
185        | 1.2345678901234e+200 | -1.2345678901234e+199
186        | 1.2345678901234e-200 | -1.2345678901234e-201
187 (3 rows)
188
189 SELECT '' AS three, f.f1, f.f1 - '-10' AS x
190    FROM FLOAT8_TBL f
191    WHERE f.f1 > '0.0';
192  three |          f1          |          x           
193 -------+----------------------+----------------------
194        |               1004.3 |               1014.3
195        | 1.2345678901234e+200 | 1.2345678901234e+200
196        | 1.2345678901234e-200 |                   10
197 (3 rows)
198
199 SELECT '' AS one, f.f1 ^ '2.0' AS square_f1
200    FROM FLOAT8_TBL f where f.f1 = '1004.3';
201  one | square_f1  
202 -----+------------
203      | 1008618.49
204 (1 row)
205
206 -- absolute value 
207 SELECT '' AS five, f.f1, @f.f1 AS abs_f1 
208    FROM FLOAT8_TBL f;
209  five |          f1          |        abs_f1        
210 ------+----------------------+----------------------
211       |                    0 |                    0
212       |               1004.3 |               1004.3
213       |               -34.84 |                34.84
214       | 1.2345678901234e+200 | 1.2345678901234e+200
215       | 1.2345678901234e-200 | 1.2345678901234e-200
216 (5 rows)
217
218 -- truncate 
219 SELECT '' AS five, f.f1, trunc(f.f1) AS trunc_f1
220    FROM FLOAT8_TBL f;
221  five |          f1          |       trunc_f1       
222 ------+----------------------+----------------------
223       |                    0 |                    0
224       |               1004.3 |                 1004
225       |               -34.84 |                  -34
226       | 1.2345678901234e+200 | 1.2345678901234e+200
227       | 1.2345678901234e-200 |                    0
228 (5 rows)
229
230 -- round 
231 SELECT '' AS five, f.f1, round(f.f1) AS round_f1
232    FROM FLOAT8_TBL f;
233  five |          f1          |       round_f1       
234 ------+----------------------+----------------------
235       |                    0 |                    0
236       |               1004.3 |                 1004
237       |               -34.84 |                  -35
238       | 1.2345678901234e+200 | 1.2345678901234e+200
239       | 1.2345678901234e-200 |                    0
240 (5 rows)
241
242 -- ceil / ceiling
243 select ceil(f1) as ceil_f1 from float8_tbl f;
244        ceil_f1        
245 ----------------------
246                     0
247                  1005
248                   -34
249  1.2345678901234e+200
250                     1
251 (5 rows)
252
253 select ceiling(f1) as ceiling_f1 from float8_tbl f;
254       ceiling_f1      
255 ----------------------
256                     0
257                  1005
258                   -34
259  1.2345678901234e+200
260                     1
261 (5 rows)
262
263 -- floor
264 select floor(f1) as floor_f1 from float8_tbl f;
265        floor_f1       
266 ----------------------
267                     0
268                  1004
269                   -35
270  1.2345678901234e+200
271                     0
272 (5 rows)
273
274 -- sign
275 select sign(f1) as sign_f1 from float8_tbl f;
276  sign_f1 
277 ---------
278        0
279        1
280       -1
281        1
282        1
283 (5 rows)
284
285 -- square root 
286 SELECT sqrt(float8 '64') AS eight;
287  eight 
288 -------
289      8
290 (1 row)
291
292 SELECT |/ float8 '64' AS eight;
293  eight 
294 -------
295      8
296 (1 row)
297
298 SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
299    FROM FLOAT8_TBL f
300    WHERE f.f1 > '0.0';
301  three |          f1          |        sqrt_f1        
302 -------+----------------------+-----------------------
303        |               1004.3 |      31.6906926399535
304        | 1.2345678901234e+200 | 1.11111110611109e+100
305        | 1.2345678901234e-200 | 1.11111110611109e-100
306 (3 rows)
307
308 -- power
309 SELECT power(float8 '144', float8 '0.5');
310  power 
311 -------
312     12
313 (1 row)
314
315 -- take exp of ln(f.f1) 
316 SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
317    FROM FLOAT8_TBL f
318    WHERE f.f1 > '0.0';
319  three |          f1          |       exp_ln_f1       
320 -------+----------------------+-----------------------
321        |               1004.3 |                1004.3
322        | 1.2345678901234e+200 | 1.23456789012338e+200
323        | 1.2345678901234e-200 | 1.23456789012339e-200
324 (3 rows)
325
326 -- cube root 
327 SELECT ||/ float8 '27' AS three;
328  three 
329 -------
330      3
331 (1 row)
332
333 SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
334  five |          f1          |       cbrt_f1        
335 ------+----------------------+----------------------
336       |                    0 |                    0
337       |               1004.3 |      10.014312837827
338       |               -34.84 |    -3.26607421344208
339       | 1.2345678901234e+200 | 4.97933859234765e+66
340       | 1.2345678901234e-200 |  2.3112042409018e-67
341 (5 rows)
342
343 SELECT '' AS five, * FROM FLOAT8_TBL;
344  five |          f1          
345 ------+----------------------
346       |                    0
347       |               1004.3
348       |               -34.84
349       | 1.2345678901234e+200
350       | 1.2345678901234e-200
351 (5 rows)
352
353 UPDATE FLOAT8_TBL
354    SET f1 = FLOAT8_TBL.f1 * '-1'
355    WHERE FLOAT8_TBL.f1 > '0.0';
356 SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
357 ERROR:  value out of range: overflow
358 SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
359 ERROR:  value out of range: overflow
360 SELECT 0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5;
361  ?column? 
362 ----------
363         2
364 (1 row)
365
366 SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
367 ERROR:  cannot take logarithm of zero
368 SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ;
369 ERROR:  cannot take logarithm of a negative number
370 SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
371 ERROR:  value out of range: underflow
372 SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
373 ERROR:  division by zero
374 SELECT '' AS five, * FROM FLOAT8_TBL;
375  five |          f1           
376 ------+-----------------------
377       |                     0
378       |                -34.84
379       |               -1004.3
380       | -1.2345678901234e+200
381       | -1.2345678901234e-200
382 (5 rows)
383
384 -- test for over- and underflow 
385 INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
386 ERROR:  "10e400" is out of range for type double precision
387 INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
388 ERROR:  "-10e400" is out of range for type double precision
389 INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
390 INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
391 -- maintain external table consistency across platforms
392 -- delete all values and reinsert well-behaved ones
393 DELETE FROM FLOAT8_TBL;
394 INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
395 INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
396 INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
397 INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
398 INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
399 SELECT '' AS five, * FROM FLOAT8_TBL;
400  five |          f1           
401 ------+-----------------------
402       |                     0
403       |                -34.84
404       |               -1004.3
405       | -1.2345678901234e+200
406       | -1.2345678901234e-200
407 (5 rows)
408