Commits

james woodyatt  committed a60a30c Merge

Merge with default branch.

  • Participants
  • Parent commits 1b57d80, 5285f6b
  • Branches sideline

Comments (0)

Files changed (1)

File cf/cf_tai64n_p.c

     
     tai64Ptr = Cf_tai64_val(tai64Val);
     ns = (uint32) Int_val(nsVal);
-    if (ns < 0 || ns > 999999999) INVALID_ARGUMENT("compose: ns > 10^9");
+    if (ns > 999999999) INVALID_ARGUMENT("compose: ns > 10^9");
     
     tai64n.s = tai64Ptr->s;
     tai64n.ns = ns;
     Cf_tai64n_t tai64n;
     double zInt, zFrac;
     int64 x;
-    int32 y;
+    int32 y, ns;
     
     zFrac = modf(Double_val(dtVal), &zInt);
     x = (int64) zInt;
     y = (int32) (zFrac * 1E9);
     
     tai64n.s = Cf_tai64n_val(tai64nVal)->s + x;
-    tai64n.ns = Cf_tai64n_val(tai64nVal)->ns + y;
-    if (tai64n.ns < 0) {
-        tai64n.ns += 1000000000;
+    ns = (int32) Cf_tai64n_val(tai64nVal)->ns + y;
+    if (ns < 0) {
+        ns += 1000000000;
         tai64n.s -= 1;
     }
-    else if (tai64n.ns >= 1000000000) {
-        tai64n.ns -= 1000000000;
+    else if (ns >= 1000000000) {
+        ns -= 1000000000;
         tai64n.s += 1;
     }
 
     if (tai64n.s >= (CF_TAI64_EPOCH << 1)) cf_tai64_range_error();
+    tai64n.ns = (uint32) ns;
     result = cf_tai64n_alloc(&tai64n);    
     CAMLreturn(result);
 }