~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/float8-exp-three-digits-win32.out

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

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