Convert scientific notation (ex: 7.533992951114973E-4) to float

Im trying to add the actual and typical field to the ML alerts on watcher, is there a method in painless to convert scientific notation to float?

                "actual" : [
                  7.533992951114973E-4
                ],

maybe something like:

         def actual = "7.533992951114973E-4";
          DecimalFormat df = new DecimalFormat();
          df.setMaximumFractionDigits(8);
          float a = Float.parseFloat((actual));
          return df.format(a);

output would be:

          "new_actual" : [
            "0.0007534"
          ]
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.