Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The types 'float' and 'double' types should not be used in Groovy as because the result of the logic element can ultimately end up in a 'double' which is currently serialized in JSON as a string. Please Therefore ensure you use 'BigDecimal' whenener whenever dealing with a decimal point number and ensure you force the type when initially getting data back from a function call..

You can do this as follows:

Code Block
num1.toBigDecimal()

As you can see in the groovy Groovy documentation, there are situations where a mathematical operation between 2 different types can end up result in a third type. For example, a BigDecimal multiplied by a Float will end up in a Double !!Double!

http://docs.groovy-lang.org/next/html/documentation/core-syntax.html

Image RemovedExtract from the Groovy documentation:

Image Added

Also, there are situations in groovy Groovy that will generate a 'double', for example the 'power of' operation:

Image RemovedImage Added

So if you do such an operation, you should perform a conversion to 'BigDecimal' afterwards. A 'double' value which is serialized to text can have an unexpected impact.For ; for example in a normal export to Excel where these values may not be recognized correctly depending on the user locale.