No announcement yet.

Comparing jittery floats in XML

  • Filter
  • Time
  • Show
Clear All
new posts

  • Comparing jittery floats in XML

    What would be a way to flag as unimportant small differences (in the number sense) in the float values embedded as attribute values in an xml?

    For example
    <volume value="106401.4991181042" />
    could be "unimportantly" different from
    <volume value="106401.4991201881" /> because they are within 1e-4 of each other.

    Thank you,
    Gene Gorokhovsky

  • #2
    Create a basic grammar rule using regular expressions.
    For example, the following regular expression could be used to define the decimal portion of a value:


    If you make the gammar element unimportant in your sessions settings tab, then differences in that portion of the value will be considered unimportant. To limit the characters to the last four digits, you could use something like this:


    You could create another grammar element like the following to ensure that numbers without decimal points are always considered to be important:


    Or a grammar element like this to ensure that decimal values are important up through the first four digits:


    Move grammar elements up or down in the list to determine their priority.
    BC v4.0.7 build 19761