This repository was archived by the owner on Dec 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ public static function fromString($strValue, $scale = null)
193
193
$ scale :
194
194
(isset ($ captures [4 ]) ? max (0 , strlen ($ captures [4 ])-1 ) : 0 );
195
195
196
- } elseif (preg_match ('/([+\-]?)([0-9](\.[0-9]+)?)[eE]([+\-]?)([1-9][0-9]*)/ ' , $ strValue , $ captures ) === 1 ) {
196
+ } elseif (preg_match ('/([+\-]?)0* ([0-9](\.[0-9]+)?)[eE]([+\-]?)([1-9][0-9]*)/ ' , $ strValue , $ captures ) === 1 ) {
197
197
198
198
// Now it's time to "unroll" the exponential notation to basic positional notation
199
199
$ sign = self ::normalizeSign ($ captures [1 ]);
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public function testNegativeSimpleString()
23
23
$ this ->assertEquals ($ n2 ->__toString (), '-1.0 ' );
24
24
}
25
25
26
- public function testExponentialNotationString_With_PositiveExponent_And_PositiveSign ()
26
+ public function testExponentialNotationString_With_PositiveExponent_And_Positive ()
27
27
{
28
28
$ this ->assertTrue (
29
29
Decimal::fromString ('1e3 ' )->equals (Decimal::fromInteger (1000 ))
@@ -45,7 +45,7 @@ public function testExponentialNotationString_With_PositiveExponent_And_Negative
45
45
);
46
46
}
47
47
48
- public function testExponentialNotationString_With_NegativeExponent_And_PositiveSign ()
48
+ public function testExponentialNotationString_With_NegativeExponent_And_Positive ()
49
49
{
50
50
$ this ->assertTrue (
51
51
Decimal::fromString ('1e-3 ' )->equals (Decimal::fromString ('0.001 ' ))
@@ -67,7 +67,7 @@ public function testExponentialNotationString_With_NegativeExponent_And_Negative
67
67
);
68
68
}
69
69
70
- public function testSimpleNotation_With_Positive_Sign ()
70
+ public function testSimpleNotation_With_PositiveSign ()
71
71
{
72
72
$ this ->assertTrue (
73
73
Decimal::fromString ('+34 ' )->equals (Decimal::fromString ('34 ' ))
@@ -78,6 +78,17 @@ public function testSimpleNotation_With_Positive_Sign()
78
78
);
79
79
}
80
80
81
+ public function testExponentialNotation_With_PositiveSign ()
82
+ {
83
+ $ this ->assertTrue (
84
+ Decimal::fromString ('+1e3 ' )->equals (Decimal::fromString ('1e3 ' ))
85
+ );
86
+
87
+ $ this ->assertTrue (
88
+ Decimal::fromString ('+0001e3 ' )->equals (Decimal::fromString ('1e3 ' ))
89
+ );
90
+ }
91
+
81
92
/**
82
93
* @expectedException Litipk\Exceptions\InvalidArgumentTypeException
83
94
* @expectedExceptionMessage $strVlue must be of type string.
You can’t perform that action at this time.
0 commit comments