[Solved] Math.Round doesn’t behave like i want it to. (X.0xxxxx numbers) [closed]


You want to do two things in single shot:

  1. Get the integer value if first digit after decimal is 0

  2. Get the rounded value upto last 2 digits if its first digit after decimal is not 0.

For second option you can use:

newValue  = Math.Round(value, 2)

Now comes the first requirement:
Once you get the decimal with 2 digits after decimal, get last two digits:

int decimalValue= (int)((newValue  - (int)newValue ) * 100);
if(decimalValue < 10)
{
  newValue = Math.Floor(value);
}

1

solved Math.Round doesn’t behave like i want it to. (X.0xxxxx numbers) [closed]