Forum Discussion

DavidLunn's avatar
DavidLunn
New Contributor
9 years ago

Local decimal seperator

I need to use the local decimal seperator. Utilities.DecimalSeparator seems to be what I want, but

'This property is obsolete and supported for backward compatibility only. The value of this property is used by obsolete methods of the Utilities object. To process float numbers, use the methods of the aqString object.'

I can not see that any of the aqString methods or properties will give me this.

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi David,

     

    aqEnvironment.GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL)

    will return the decimal separator.

     

    But if what you want to do is convert a string to a number or a number to a string according to the locale settings, use aqConvert.StrToFloat and aqConvert.FloatToStr instead. These methods use the locale-specific decimal separator when producing the output.

    • DavidLunn's avatar
      DavidLunn
      New Contributor

      In this instance I specifically need the decimal seperator character, so your reply is exactly what I need. Thanks.

  • NisHera's avatar
    NisHera
    Valued Contributor

    try following two lines

     

    Log.Message(aqString.Format("Value with two digit:% #.2f",123.45678));
    Log.Message(aqString.Format("Value without digits:%i",123.85678  ));

    more on hear