Skip to content

wikibase

John Erling Blad edited this page Oct 9, 2019 · 3 revisions

Wikibase

The extension Wikibase Client use Number, which has DataValues, which may use either bcmath or floats (double) to implement numbers.

Wikibase numbers has some weirdness of its own, and some of them will have an impact on BCmath if both are used inside the same environment.

Example of stored number is "+10.01", which follows the same assumptions as BCmath.

Wikibase does not use infinite markers, but as BCmath does not store anything back to Wikibase that should not be a problem.

Precision

Numbers coming from Wikibase will have a max length imposed upon them, but the same restriction does not exist for BCmath. If a number is passed on through Wikibase, and the same number follows some other path, then those two numbers might not be the same. If the number is truncated, due to a string limit, then the number coming through Wikibase might be invalid. If the number is turned into a float (double) then it might have lost precision.

Scaling

There are some differences in scaling, and in particular Numbers will use escalated scaling for multiplication. That will give false precision. BCmath does not use escalated scaling, and can thus give unexpected results.

Rounding

Numbers implement rounding, while BCmath does not.

Increment

Numbers implement increment (bump()), while BCmath does not.

Decrement

Numbers implement decrement (slump()), while BCmath does not.

Left shift

Numbers implement left shift (shiftLeft()), while BCmath does not.

Right shift

Numbers implement right shift (shiftRight()), while BCmath does not.

Clone this wiki locally