Ho to change Number Format

Hi ,
i have to change value 514,314,982 to 514.31

Does this mean you want to truncate last 4 numbers always?

@rahulsharma yes

Store that value in a variable
then just assign this value to new variable/existing variable
variable.toString.Substring(0,varStr.Length-4).Replace(“,”,“.”)

@Anand_Designer

Let’s say inputString = “514,314,982”

        outputString = inputString.SubString(0,inputString.Length-5).Replace(",",".")

Dear @lakshman, seems it is the same approach that I mentioned above. Anything new you wanted to propose?

Also the length should be - 4 as last 4 digit needs to be truncated

Let me know if I misunderstood anything…

@rahulsharma

Your expression will give output as 514.314 but his expected output is 514.31.

And also we should subtract 5 from the length of the string as index starting from 0. Hope you understood.

oh got you, Saver! Thank you!
Yes it should be 5 as there’s zero-based index

1 Like

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