title: Swift isPowerofThree can not pass 243
body: <p>My project mission is to find out if an integer is power of three. My code can pass 0 ,1, 3,9,27,81 test cases, but 243. 
  And when I try to print out to debug, I found a weird thing. When I input 243, I print out log3(243), it gives me 5.0, which is correct. But I tried to print log3(243) % 1, it gives me 0.99999999999, which is so weird. </p>
  
  <pre><code>class Solution {
  func isPowerOfThree(n: Int) -&gt; Bool
  {
      //print("log3(n): \(log3(Double(n)))")
  
      if n == 0
      {
          return true
      }
  
      if n == 1
      {
          return true
      }
  
      //print("weird here: \(log3(Double(n)) % 1)" )
  
      if log3(Double(n)) % 1 == 0.0
      {
  
          return true
      }
      //print("log3: \(log3(Double(n)))")
      //print("floor log3: \(floor(log3(Double(n))))")
      //print("log3: \(Int(log3(Double(n))))")
      return false
  }
  
  func log3(val: Double) -&gt; Double
  {
      return log(val)/log(3.0)
  }
  
  }
  
  var test = Solution()
  var result = test.isPowerOfThree(243)
  print(result)
  </code></pre>