]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/nfrs.cpp
ICU-59117.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / nfrs.cpp
index e2c41f2b7d084c0e6111919fb8d987e0f0dad8c2..129b0b32dadf3d53537a6641fde634eb7d1ebce2 100644 (file)
@@ -1,10 +1,12 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 ******************************************************************************
 *   Copyright (C) 1997-2015, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 ******************************************************************************
 *   file name:  nfrs.cpp
 /*
 ******************************************************************************
 *   Copyright (C) 1997-2015, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 ******************************************************************************
 *   file name:  nfrs.cpp
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -21,6 +23,7 @@
 #include "nfrule.h"
 #include "nfrlist.h"
 #include "patternprops.h"
 #include "nfrule.h"
 #include "nfrlist.h"
 #include "patternprops.h"
+#include "putilimp.h"
 
 #ifdef RBNF_DEBUG
 #include "cmemory.h"
 
 #ifdef RBNF_DEBUG
 #include "cmemory.h"
@@ -542,7 +545,7 @@ NFRuleSet::findNormalRule(int64_t number) const
         // an explanation of the rollback rule).  If we do, roll back
         // one rule and return that one instead of the one we'd normally
         // return
         // an explanation of the rollback rule).  If we do, roll back
         // one rule and return that one instead of the one we'd normally
         // return
-        if (result->shouldRollBack((double)number)) {
+        if (result->shouldRollBack(number)) {
             if (hi == 1) { // bad rule set, no prior rule to rollback to from this base
                 return NULL;
             }
             if (hi == 1) { // bad rule set, no prior rule to rollback to from this base
                 return NULL;
             }
@@ -827,18 +830,20 @@ int64_t util64_fromDouble(double d) {
     return result;
 }
 
     return result;
 }
 
-int64_t util64_pow(int32_t r, uint32_t e)  { 
-    if (r == 0) {
+int64_t util64_pow(int32_t base, uint16_t exponent)  { 
+    if (base == 0) {
         return 0;
         return 0;
-    } else if (e == 0) {
-        return 1;
-    } else {
-        int64_t n = r;
-        while (--e > 0) {
-            n *= r;
-        }
-        return n;
     }
     }
+    int64_t result = 1;
+    int64_t pow = base;
+    while (exponent > 0) { 
+        if ((exponent & 1) == 1) { 
+            result *= pow; 
+        } 
+        pow *= pow; 
+        exponent >>= 1; 
+    } 
+    return result;
 }
 
 static const uint8_t asciiDigits[] = { 
 }
 
 static const uint8_t asciiDigits[] = {