Ad
  • Default User Avatar

    Okey, I got your point. The logic we apply to intger bases will not work for PI. (i feel my CS101 was lie.. lol)
    I'm developing another logic based on your first comment. Will increase powers of PI till just below the number to convert.
    Kind of greedy approach? Anyway thanks.. -ve votes taken back.

  • Default User Avatar

    You did not suggested any formula. I know that my logic does not work, thats why wanted to know the correct logic.

  • Default User Avatar

    I am sorry for not understanding. I know that any number raised to power 0 returns 1.
    But, I will try to explain my doubt:

    Lets say, we want to convert 13(in base 10) into binary. Then, 13/2=6 with remainder 1. Hence last digit in binary form will be 1.
    Similarly, in base PI, 13/PI = 4 with remainder 0.43364. So, why last digit in base PI is 3? When it should be 0 according to my calculation.

  • Default User Avatar

    I did not understand the following test case: converter(13) #returns '103'
    13 (in base 10) = 103 (in base PI)
    => 1PI^2 + 0PI^1 + 3*PI^0

    My question is: why if 13/3.14159 = 4.13803.
    Why did the value unit place value(in 103) was chosen as 3 if remainder is 0.13803 from above.

    Kindly help, I am not getting the logic to convert to Base PI.

  • Default User Avatar

    Got your point, Thanks. Now, I am wondering why do they complicate in books and try to backtrack along the diagonal which is so complex to implement.

  • Default User Avatar

    I did not get the backtracking loop. I followed the WiKi, started from the bottom right. THe process moved up or sidewas as much as possible. Only when this was not possible, it moved diagonal and checked if value decrement. Thus, tougher one.

    Your is so simple. Can you please shed some light on it?

  • Default User Avatar

    I am getting the same. Expected 50, Got: 51
    Any clues on this? Is this a faulty test case. I am using Java.

    Update -- Solved, it was my wrong.