Index: Zend/Measure/Number.php =================================================================== --- Zend/Measure/Number.php (revision 8221) +++ Zend/Measure/Number.php (working copy) @@ -237,9 +237,8 @@ require_once 'Zend/Measure/Exception.php'; throw new Zend_Measure_Exception($e->getMessage()); } - if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { - $value = call_user_func(Zend_Locale_Math::$sqrt, call_user_func(Zend_Locale_Math::$pow, $value, 2)); - } + preg_match('/[0123456789]+/', $value, $ergebnis); + $value = $ergebnis[0]; break; } @@ -304,20 +303,39 @@ */ private function fromDecimal($value, $type) { + $tempvalue = $value; if ($this->_UNITS[$type][0] <= 16) { +print "\n\nFROM:'".$this->_UNITS[$type][0]."'"; $newvalue = ""; $count = 200; while (call_user_func(Zend_Locale_Math::$comp, $value, 0, 25) <> 0) { +print "\nCOUNT:'$count'"; +print "\nVALUE:'$value'"; +print "\nCOMP:'".call_user_func(Zend_Locale_Math::$comp, $value, 0, 25)."'"; $target = call_user_func(Zend_Locale_Math::$mod, $value, $this->_UNITS[$type][0]); + if (($value != $tempvalue) && (($value * 2) > $oldvalue)) { +print "\nCORRECTION"; + $target = 0; + --$value; + } +print "\nTARG:'$target'"; + $oldvalue = $value; + $value = call_user_func(Zend_Locale_Math::$div, $value, $this->_UNITS[$type][0], 0); + if (call_user_func(Zend_Locale_Math::$add, $value, $target) > $oldvalue) { + --$value; + } +print "\nOLD:'$oldvalue':'$value'"; $target = strtoupper( dechex($target) ); $newvalue = $target . $newvalue; - $value = call_user_func(Zend_Locale_Math::$div, $value, $this->_UNITS[$type][0], 0); +print "\nNEWV:'$newvalue'"; if (($value == 1) and ($newvalue == 1)) { +print "\nBREAK!!!!"; break; } --$count; if ($count == 0) { - break; + require_once 'Zend/Measure/Exception.php'; + throw new Zend_Measure_Exception("Your value '$tempvalue' cannot be processed because it extends 200 digits"); } } } @@ -328,17 +346,28 @@ $romanval = array_values( array_reverse(self::$_ROMAN) ); $romankey = array_keys( array_reverse(self::$_ROMAN) ); $count = 200; - while(call_user_func(Zend_Locale_Math::$comp, $value, 0, 25) > 0) { +print "\n\nFROM:'ROMAN'"; + while(call_user_func(Zend_Locale_Math::$comp, $value, 0, 25) <> 0) { while ($value >= $romanval[$i]) { +print "\nCOUNT:'$count'"; +print "\nVALUE:'$value'"; +print "\nROMVA:'".$romanval[$i]."'"; $value -= $romanval[$i]; $newvalue .= $romankey[$i]; +print "\nNEWVA:'".$newvalue."'"; + + if ($value < 1) { +print "\nBREAK!!!!"; + break; + } + --$count; + if ($count == 0) { + require_once 'Zend/Measure/Exception.php'; + throw new Zend_Measure_Exception("Your value '$tempvalue' cannot be processed because it extends 200 digits"); + } } $i++; - --$count; - if ($count == 0) { - break; - } }