6 COMMENTS

  1. Why the log value is not calculated and stored in float. I think it should be float because using int always degrades a value to integer from float rounding the value to nearest integer (that can be in some cases wrong).

    My point is that data type to store n and r can be int but result that is log n to base r must be stored in a float, so that we can get some values after decimal. Log calculations are meant to be precise and thats why we use values after decimal too. Using above code we will always get same value for a particular range.

    ie. Considerng base 10, Log 10 = 1 and Log 100 = 2 and for any n in range [10, 99] , your code will always output 1, That’s quite right, but not absolutely right that can be achieved If we use float.

LEAVE A REPLY