I'm comparing some files with Beyond Compare (3.3).
I have some minor diffs on floating point numbers.
Is there a way to tell BC to ignore such differences after a certain decimal place?
I'm comparing some files with Beyond Compare (3.3).
I have some minor diffs on floating point numbers.
Is there a way to tell BC to ignore such differences after a certain decimal place?
Beyond Compare's Text Compare can't ignore differences after a certain decimal place.
Differences can be ignored as text, either as plain text or regular expressions.
As an example, to ignore all numeric characters after a decimal point:
I would like to extend the accepted answer a little bit.
First, you should use \.\d+ with an backslash before the . otherwise the . will match any character.
With the accepted solution, you might run into numerical problems you do not want, for example if you want to compare 0.99 with 1.01.
As far as I know there is no perfect solution in Beyond Compare for this, but you can reduce the number of mismatches by defining the Grammar as a List instead of Basic which allows you to have multiple rules.
If you set up the list like this:
\.\d+
(0|1)\.\d+
(1|2)\.\d+
(2|3)\.\d+
(3|4)\.\d+
(4|5)\.\d+
(5|6)\.\d+
(6|7)\.\d+
(7|8)\.\d+
(8|9)\.\d+
(9|0)\.\d+
you will be able to catch an overrun by a single integer place before the ..
However, this will not work for more integer places, so if you have 109.99 and 110.01, this will fail and still show up as a difference. I tried to add more rules to support more integer places, like (09|10)\.\d+, but that did not seem to work.
Some other corner cases like .9 vs 1.0 will also not work, so be advised that both the accepted solution and mine are not perfect, but they might help you cut down on unwanted differences.