Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickanderson/a7faeabf22d0137f281531bc618d7eca to your computer and use it in GitHub Desktop.
Save nickanderson/a7faeabf22d0137f281531bc618d7eca to your computer and use it in GitHub Desktop.

How to compare values of two string representations of a double

bundle agent main
{
  vars:
      "one" real => "5";
      "two" real => "5.000000";
      "three" string => "5";
      "four" string => "5.000000";

  classes:
      "set1_equal" expression => eval("$(one)==$(two)", class, infix);
      "set2_equal" expression => eval("$(three)==$(four)", class, infix);

  reports:
    "CFEngine $(sys.cf_version)"; 
    
    set1_equal::
      "$(one) == $(two)";

    set2_equal::
      "$(three) == $(four)";

}
R: CFEngine 3.14.0a.4e12fcf75
R: 5.000000 == 5.000000
R: 5 == 5.000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment