Search code examples
genexus

How to remove zeros after the decimal point


I want to remove the zeros after the decimal point and display

Input 123.111 → Display 123.111

Input 123.000 → Display 123


Solution

  • The easiest way to do this is to use a string replace.

    Here is the documentation: https://wiki.genexus.com/commwiki/servlet/wiki?12710,Replace+method

    An example would be:

    &String1 = '123.000' &String2 = &String1.Replace('.000', '')

    If you are starting with a numeric variable, for example, N(10,3), then convert it to a string first: &String1 = &Numeric1.ToString().Trim()