0

I am trying to round a number to the closest number in a geometric sequence having a factor of 2 between each number.

Lets say I have:

int num = 30;

I would need "num" to be rounded to 32

Matt J
  • 99
  • 2
  • 12

1 Answers1

2
double logValue = Math.Log(30, 2);   
double ceilingValue= Math.Round(logValue);

double result = Math.Pow(2, ceilingValue);
mybirthname
  • 17,949
  • 3
  • 31
  • 55