diff --git a/corsika/detail/media/GeomagneticModel.inl b/corsika/detail/media/GeomagneticModel.inl
index 1747f95132082c26a06f58ccd2ef5d9e482d1395..fc3f0711d36c69208658416df077c84d97dff630 100644
--- a/corsika/detail/media/GeomagneticModel.inl
+++ b/corsika/detail/media/GeomagneticModel.inl
@@ -149,8 +149,8 @@ namespace corsika {
       p.h = p.h + (year - epoch) * p.dh;
       if (next_Epoch != 0) {
         ParameterLine next_p = parameters_[next_Epoch][j];
-        p.g = p.g + (next_p.g - p.g) * (year - epoch) / (next_Epoch - epoch);
-        p.h = p.h + (next_p.h - p.h) * (year - epoch) / (next_Epoch - epoch);
+        p.g = p.g + (next_p.g - p.g) * (year - epoch) / (double(next_Epoch) - epoch);
+        p.h = p.h + (next_p.h - p.h) * (year - epoch) / (double(next_Epoch) - epoch);
       }
 
       legendre = pow(-1, p.m) * std::assoc_legendre(p.n, p.m, sin(lat_sph));
diff --git a/tests/media/testMagneticField.cpp b/tests/media/testMagneticField.cpp
index de8b12fabb1522e8031c86cc0661131b9fae4e94..f46297fa6549cd7b7240a7ab6ee5c9c00fabf7ce 100644
--- a/tests/media/testMagneticField.cpp
+++ b/tests/media/testMagneticField.cpp
@@ -104,7 +104,7 @@ TEST_CASE("UniformMagneticField w/ Homogeneous Medium") {
       MagneticFieldVector Earth_B_4 = igrf.getField(2012, 0_km, 0, -120);
       CHECK(Earth_B_1.getX(gCS) / 1_nT == Approx(5821).margin(0.5));
       CHECK(Earth_B_1.getY(gCS) / 1_nT == Approx(-14796).margin(0.5));
-      CHECK(Earth_B_1.getZ(gCS) / 1_nT == Approx(497756).margin(0.5));
+      CHECK(Earth_B_1.getZ(gCS) / 1_nT == Approx(49776).margin(0.5));
       CHECK(Earth_B_2.getX(gCS) / 1_nT == Approx(2957).margin(0.5));
       CHECK(Earth_B_2.getY(gCS) / 1_nT == Approx(-1014).margin(0.5));
       CHECK(Earth_B_2.getZ(gCS) / 1_nT == Approx(-57610).margin(0.5));