Your error is occuring on the following line with the last parameter: 90/#t1 let #val = cond(trunc(#t1,0) = 0,0,90/#t1) Since #t1 = 0, the division can't be calculated.