Skip to content

Commit dbe9c90

Browse files
author
Markus Nullmeier
committed
Fix numerical constants
Change the decimal form of numerical constants to the necessary and sufficient precision for the input of 8-byte IEEE floating point numbers. Since the x87 floating point math that is still in use for 32 bit x86 builds uses 10-byte floats internally, which results in small differences for some input (and also to sometimes seemingly unpredictable results with respect to compiler options), some more changes were necessary: - change sellipse_check() - reduce floating point output for Spoint tests by 2 decimal digits in order to offset rounding problems for HMS input - add missing set_sphere_output_precision() to aggregate data test
1 parent 1569bfc commit dbe9c90

File tree

6 files changed

+123
-113
lines changed

6 files changed

+123
-113
lines changed

ellipse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ sellipse_check(SELLIPSE *e)
7575

7676
sp.lng = e->phi;
7777
spoint_check(&sp);
78-
if (sp.lng < PI)
78+
if (PI - sp.lng >= PI_EPS)
7979
e->phi = sp.lng;
8080
else
8181
e->phi = sp.lng - PI;

expected/points.out

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -259,21 +259,21 @@ SELECT spoint(0.0 , 2.141592653589793116);
259259

260260
-- dist(spoint,spoint)
261261
SELECT dist('( 0h 2m 30s , 0d 0m 0s)'::spoint,'( 0h 0m 30s , 0d 0m 0s)'::spoint);
262-
dist
263-
---------------------
264-
0.00872664625997165
262+
dist
263+
-------------------
264+
0.008726646259972
265265
(1 row)
266266

267267
SELECT dist('( 0h 2m 30s , 0d 0m 0s)'::spoint,'( 0h 2m 30s , 10d 0m 0s)'::spoint);
268-
dist
269-
-------------------
270-
0.174532925199433
268+
dist
269+
-----------------
270+
0.1745329251994
271271
(1 row)
272272

273273
SELECT dist('( 0h 2m 30s , 0d 0m 0s)'::spoint,'( 0h 2m 30s , -10d 0m 0s)'::spoint);
274-
dist
275-
-------------------
276-
0.174532925199433
274+
dist
275+
-----------------
276+
0.1745329251994
277277
(1 row)
278278

279279
SELECT dist('( 0h 2m 30s , 95d 0m 0s)'::spoint,'( 12h 2m 30s , 85d 0m 0s)'::spoint);
@@ -283,9 +283,9 @@ SELECT dist('( 0h 2m 30s , 95d 0m 0s)'::spoint,'( 12h 2m 30s , 85d 0m 0s)'::spoi
283283
(1 row)
284284

285285
SELECT dist('( 24h 2m 30s , 10d 0m 0s)'::spoint,'( 0h 2m 30s , -10d 0m 0s)'::spoint);
286-
dist
287-
-------------------
288-
0.349065850398866
286+
dist
287+
-----------------
288+
0.3490658503989
289289
(1 row)
290290

291291
SELECT dist('( 0h 2m 30s , 90d 0m 0s)'::spoint,'( 12h 2m 30s , 90d 0m 0s)'::spoint);
@@ -302,87 +302,87 @@ SELECT dist('( 0h 2m 30s , -90d 0m 0s)'::spoint,'( 12h 2m 30s , -90d 0m 0s)'::sp
302302

303303
-- long(spoint)
304304
SELECT long('( 0h 2m 30s , 0d 0m 0s)'::spoint);
305-
long
306-
--------------------
307-
0.0109083078249646
305+
long
306+
------------------
307+
0.01090830782496
308308
(1 row)
309309

310310
SELECT long('( 0h 2m 30s ,95d 0m 0s)'::spoint);
311-
long
312-
------------------
313-
3.15250096141476
311+
long
312+
----------------
313+
3.152500961415
314314
(1 row)
315315

316316
SELECT long('( 0h 2m 30s ,85d 0m 0s)'::spoint);
317-
long
318-
--------------------
319-
0.0109083078249646
317+
long
318+
------------------
319+
0.01090830782496
320320
(1 row)
321321

322322
SELECT long('( 0h 2m 30s ,-95d 0m 0s)'::spoint);
323-
long
324-
------------------
325-
3.15250096141476
323+
long
324+
----------------
325+
3.152500961415
326326
(1 row)
327327

328328
SELECT long('( 0h 2m 30s ,-85d 0m 0s)'::spoint);
329-
long
330-
--------------------
331-
0.0109083078249646
329+
long
330+
------------------
331+
0.01090830782496
332332
(1 row)
333333

334334
SELECT long('( 0h 2m 30s ,90d 0m 0s)'::spoint);
335-
long
336-
--------------------
337-
0.0109083078249646
335+
long
336+
------------------
337+
0.01090830782496
338338
(1 row)
339339

340340
SELECT long('( 0h 2m 30s ,-90d 0m 0s)'::spoint);
341-
long
342-
--------------------
343-
0.0109083078249646
341+
long
342+
------------------
343+
0.01090830782496
344344
(1 row)
345345

346346
SELECT long('(24h 2m 30s , 0d 0m 0s)'::spoint);
347-
long
348-
--------------------
349-
0.0109083078249643
347+
long
348+
------------------
349+
0.01090830782496
350350
(1 row)
351351

352352
SELECT long('(24h 2m 30s ,95d 0m 0s)'::spoint);
353-
long
354-
------------------
355-
3.15250096141476
353+
long
354+
----------------
355+
3.152500961415
356356
(1 row)
357357

358358
SELECT long('(24h 2m 30s ,85d 0m 0s)'::spoint);
359-
long
360-
--------------------
361-
0.0109083078249643
359+
long
360+
------------------
361+
0.01090830782496
362362
(1 row)
363363

364364
SELECT long('(24h 2m 30s ,-95d 0m 0s)'::spoint);
365-
long
366-
------------------
367-
3.15250096141476
365+
long
366+
----------------
367+
3.152500961415
368368
(1 row)
369369

370370
SELECT long('(24h 2m 30s ,-85d 0m 0s)'::spoint);
371-
long
372-
--------------------
373-
0.0109083078249643
371+
long
372+
------------------
373+
0.01090830782496
374374
(1 row)
375375

376376
SELECT long('(24h 2m 30s ,90d 0m 0s)'::spoint);
377-
long
378-
--------------------
379-
0.0109083078249643
377+
long
378+
------------------
379+
0.01090830782496
380380
(1 row)
381381

382382
SELECT long('(24h 2m 30s ,-90d 0m 0s)'::spoint);
383-
long
384-
--------------------
385-
0.0109083078249643
383+
long
384+
------------------
385+
0.01090830782496
386386
(1 row)
387387

388388
-- lat(spoint)
@@ -393,39 +393,39 @@ SELECT lat('( 0h 2m 30s , 0d 0m 0s)'::spoint);
393393
(1 row)
394394

395395
SELECT lat('( 0h 2m 30s ,95d 0m 0s)'::spoint);
396-
lat
397-
------------------
398-
1.48352986419518
396+
lat
397+
----------------
398+
1.483529864195
399399
(1 row)
400400

401401
SELECT lat('( 0h 2m 30s ,85d 0m 0s)'::spoint);
402-
lat
403-
------------------
404-
1.48352986419518
402+
lat
403+
----------------
404+
1.483529864195
405405
(1 row)
406406

407407
SELECT lat('( 0h 2m 30s ,-95d 0m 0s)'::spoint);
408-
lat
409-
-------------------
410-
-1.48352986419518
408+
lat
409+
-----------------
410+
-1.483529864195
411411
(1 row)
412412

413413
SELECT lat('( 0h 2m 30s ,-85d 0m 0s)'::spoint);
414-
lat
415-
-------------------
416-
-1.48352986419518
414+
lat
415+
-----------------
416+
-1.483529864195
417417
(1 row)
418418

419419
SELECT lat('( 0h 2m 30s ,90d 0m 0s)'::spoint);
420-
lat
421-
-----------------
422-
1.5707963267949
420+
lat
421+
----------------
422+
1.570796326795
423423
(1 row)
424424

425425
SELECT lat('( 0h 2m 30s ,-90d 0m 0s)'::spoint);
426-
lat
427-
------------------
428-
-1.5707963267949
426+
lat
427+
-----------------
428+
-1.570796326795
429429
(1 row)
430430

431431
SELECT lat('(24h 2m 30s , 0d 0m 0s)'::spoint);
@@ -435,39 +435,39 @@ SELECT lat('(24h 2m 30s , 0d 0m 0s)'::spoint);
435435
(1 row)
436436

437437
SELECT lat('(24h 2m 30s ,95d 0m 0s)'::spoint);
438-
lat
439-
------------------
440-
1.48352986419518
438+
lat
439+
----------------
440+
1.483529864195
441441
(1 row)
442442

443443
SELECT lat('(24h 2m 30s ,85d 0m 0s)'::spoint);
444-
lat
445-
------------------
446-
1.48352986419518
444+
lat
445+
----------------
446+
1.483529864195
447447
(1 row)
448448

449449
SELECT lat('(24h 2m 30s ,-95d 0m 0s)'::spoint);
450-
lat
451-
-------------------
452-
-1.48352986419518
450+
lat
451+
-----------------
452+
-1.483529864195
453453
(1 row)
454454

455455
SELECT lat('(24h 2m 30s ,-85d 0m 0s)'::spoint);
456-
lat
457-
-------------------
458-
-1.48352986419518
456+
lat
457+
-----------------
458+
-1.483529864195
459459
(1 row)
460460

461461
SELECT lat('(24h 2m 30s ,90d 0m 0s)'::spoint);
462-
lat
463-
-----------------
464-
1.5707963267949
462+
lat
463+
----------------
464+
1.570796326795
465465
(1 row)
466466

467467
SELECT lat('(24h 2m 30s ,-90d 0m 0s)'::spoint);
468-
lat
469-
------------------
470-
-1.5707963267949
468+
lat
469+
-----------------
470+
-1.570796326795
471471
(1 row)
472472

473473
-- operators for points -------------
@@ -607,21 +607,21 @@ SELECT '( 0h 2m 30s , 0d 0m 0s)'::spoint<>'( 12h 2m 30s , 45d 0m 0s)'::spoint;
607607

608608
-- <-> operator ---------------------
609609
SELECT '( 0h 2m 30s , 0d 0m 0s)'::spoint<->'( 0h 0m 30s , 0d 0m 0s)'::spoint;
610-
?column?
611-
---------------------
612-
0.00872664625997165
610+
?column?
611+
-------------------
612+
0.008726646259972
613613
(1 row)
614614

615615
SELECT '( 0h 2m 30s , 0d 0m 0s)'::spoint<->'( 0h 2m 30s , 10d 0m 0s)'::spoint;
616-
?column?
617-
-------------------
618-
0.174532925199433
616+
?column?
617+
-----------------
618+
0.1745329251994
619619
(1 row)
620620

621621
SELECT '( 0h 2m 30s , 0d 0m 0s)'::spoint<->'( 0h 2m 30s , -10d 0m 0s)'::spoint;
622-
?column?
623-
-------------------
624-
0.174532925199433
622+
?column?
623+
-----------------
624+
0.1745329251994
625625
(1 row)
626626

627627
SELECT '( 0h 2m 30s , 95d 0m 0s)'::spoint<->'( 12h 2m 30s , 85d 0m 0s)'::spoint;
@@ -631,9 +631,9 @@ SELECT '( 0h 2m 30s , 95d 0m 0s)'::spoint<->'( 12h 2m 30s , 85d 0m 0s)'::spoint;
631631
(1 row)
632632

633633
SELECT '( 24h 2m 30s , 10d 0m 0s)'::spoint<->'( 0h 2m 30s , -10d 0m 0s)'::spoint;
634-
?column?
635-
-------------------
636-
0.349065850398866
634+
?column?
635+
-----------------
636+
0.3490658503989
637637
(1 row)
638638

639639
SELECT '( 0h 2m 30s , 90d 0m 0s)'::spoint<->'( 12h 2m 30s , 90d 0m 0s)'::spoint;

0 commit comments

Comments
 (0)