TransWikia.com

Comparing floating point numbers and indicate common digits

TeX - LaTeX Asked by GertVdE on August 10, 2021

A common way to compare computed numbers using a "new algorithm" to a reference solution is by indicating the correct (or better said, in common) digits of the two numbers. This indication could be a change of font (italic or bold) or a change of font/background colour. What would be the LaTeX way to achieve this? See example in screenshot.

The comparison should be done by numerically using floor(-log10(abs(a-b))) ) and not on the display of the digits themselves (see comment of @DavidCarlisle)

I use the siunitx package’s command num{} to parse, format and align these numbers in a table, using the S column type (one column for the reference, one column for the newly computed values). So it would be cool if I could keep doing that, relying on siunitx.

I guess a solution could be to declare a new command, derived from num{} that takes two numbers, the reference and the one to be compared to (could be the same to force the reference value to be formatted in bold, for example). But this is way beyond my LaTeX skills…

example

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP