title: Groovy error with method mod or %
body: <p>I just started to program in Groovy, I have got this error and I wanted to see if anyone could help me to work it out.</p>
  
  <pre><code>java.lang.UnsupportedOperationException: Cannot use mod() on this number type: java.math.BigDecimal with value: 5
      at Script1.hailstone(Script1.groovy:8)
      at Script1$hailstone.callCurrent(Unknown Source)
      at Script1.hailstone(Script1.groovy:11)
      at Script1$hailstone.callCurrent(Unknown Source)
      at Script1.hailstone(Script1.groovy:14)
      at Script1$_run_closure1.doCall(Script1.groovy:1)
      at Script1.run(Script1.groovy:1)
  </code></pre>
  
  <p>I have the following Groovy code </p>
  
  <pre><code>def list = [1,2,3].findAll{it-&gt; hailstone(it)}
  
  def hailstone(num){
      if(num==1){
          return 1;
      }
      println num
      println num.mod(2)
      if(num.mod(2)==0){
          num = num/2;
          return 1 + hailstone(num)
      }else{
          num = 3*num + 1
          return 1 + hailstone(num)
      }
  }
  </code></pre>
  
  <p>​
  ​</p>
  
  <p>and the output:</p>
  
  <pre><code>2
  0
  3
  1 
  10
  0
  5
  </code></pre>
  
  <p>and then it suddenly throws an error on 5.mod(2).</p>
  
  <p>Thanks in advance.</p>