Math Operations

  • myDouble = Math.Round(12.5, MidpointRounding.AwayFromZero) [rounds digit 5 up and returns a double; here: 13]
  • myDouble = Math.Round(12.5, MidpointRounding.ToEven) [rounds digit 5 to the nearest even number and returns a double; here: 12]
  • rand = new Random() [initializes a new Random object]
  • myRandomInteger = rand.Next(1, 101) [generates a random integer between 1 and 100]
  • myRandomDouble = rand.NextDouble(1, 51) [generates a random double between 1 and 50]
Was this article helpful?
0 out of 0 found this helpful