wmde / Number

Numerical value objects, parsers and formatters
Other
18 stars 6 forks source link

DecimalMath::product: Round to net exceed 127 chars #121

Closed mariushoch closed 6 years ago

mariushoch commented 6 years ago

Bug: T208106

JeroenDeDauw commented 6 years ago

Not seeing anything wrong but am quite confused by the test, so can't +1

mariushoch commented 6 years ago

Not seeing anything wrong but am quite confused by the test, so can't +1

The test is esentially multiplying 0.3333… (the closest we can get to that with our 127 chars) by 0.2222… (the closest we can get to that with our 127 chars), and making sure that the resulting number exactly fits into the 127 char limit.

manicki commented 6 years ago

Wouldn't some assert that strlen is (no more than) 127 be the even more clear description of the tested behaviour?

JeroenDeDauw commented 6 years ago

I don't get the '+0.' . str_repeat( '2', 127 - 6 ) bit. That string is not 127 chars. Why the -6?

mariushoch commented 6 years ago

I don't get the '+0.' . str_repeat( '2', 127 - 6 ) bit. That string is not 127 chars. Why the -6?

Actually this should be -4… two chars for "+" and ".", and two for the integer parts (the two "0").

I'll update this as suggested by @manicki.

JeroenDeDauw commented 6 years ago

PR for releasing this: https://github.com/DataValues/Number/pull/120