]> granicus.if.org Git - icu/commitdiff
ICU-8854 integral division result cast to double (and floored).
authorAbhinav Gupta <mail@abhinavg.net>
Mon, 24 Oct 2011 19:14:03 +0000 (19:14 +0000)
committerAbhinav Gupta <mail@abhinavg.net>
Mon, 24 Oct 2011 19:14:03 +0000 (19:14 +0000)
Unnecessary because integral division already truncates the result.

X-SVN-Rev: 30854

icu4j/main/classes/core/src/com/ibm/icu/util/IndianCalendar.java

index eef93776e754c9cf65b269c2cf8b9b8eeefe76a4..fea2bbd69a8829651e59bca4b5b17f1e77443705 100644 (file)
@@ -380,11 +380,11 @@ public class IndianCalendar extends Calendar {
         } else {
               mday = yday - leapMonth;
               if (mday < (31 * 5)) {
-                 IndianMonth = (int)Math.floor(mday / 31) + 1;
+                 IndianMonth = mday / 31 + 1;
                  IndianDayOfMonth = (mday % 31) + 1;
               } else {
                  mday -= 31 * 5;
-                 IndianMonth = (int)Math.floor(mday / 30) + 6;
+                 IndianMonth = mday / 30 + 6;
                  IndianDayOfMonth = (mday % 30) + 1;
               }
         }
@@ -508,18 +508,15 @@ public class IndianCalendar extends Calendar {
      */
     private static double gregorianToJD(int year, int month, int date) {
        double JULIAN_EPOCH = 1721425.5;
-       double jd = (JULIAN_EPOCH - 1) +
-          (365 * (year - 1)) +
-          Math.floor((year - 1) / 4) +
-          (-Math.floor((year - 1) / 100)) +
-          Math.floor((year - 1) / 400) +
-          Math.floor((((367 * month) - 362) / 12) +
-                ((month <= 2) ? 0 :
-                 (isGregorianLeap(year) ? -1 : -2)
-                ) +
-                date);
-       
-       return jd;
+       int y = year - 1;
+       int result = (365 * y)
+                  + (y / 4)
+                  - (y / 100)
+                  + (y / 400)
+                  + (((367 * month) - 362) / 12)
+                  + ((month <= 2) ? 0 : (isGregorianLeap(year) ? -1 : -2))
+                  + date;
+       return result - 1 + JULIAN_EPOCH;
     }
     
     /*