Skip to content

Commit 28ffa1a

Browse files
committed
Improve the accuracy of the degree unit.
Currently the factor of a the base radian unit is hard coded with accuracy to 9 signigicant digits. This changes to computing the factor from the variable `$PI` defined in `Units.pm` to be `4 atan2(1, 1)` which gives as good of accuracy as can be obtained (seems to be 15 significant digits of accuracy). I have seen propogation of rounding error occur too frequently with the current estimate. That of course can still happen, but this makes it better at least.
1 parent c50623b commit 28ffa1a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/Units.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ our %known_units = (
9292

9393
# ANGLES: fundamental unit rad (radian)
9494
deg => { # degree
95-
factor => 0.0174532925,
95+
factor => $PI / 180,
9696
rad => 1,
9797
aliases => [ "\x{00B0}", 'degree', 'degrees' ]
9898
},

0 commit comments

Comments
 (0)