Compile[{}, Module[{n}, n = Length[{1, 2, 3, 4}]; n = n/2]]
The above code will emit errors
Compile::cset: Variable n of type _Integer encountered in assignment of type _Real. >>
Compile::extscalar: n=n/2 cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >>
Compile::cset: Variable n of type _Integer encountered in assignment of type _Real. >>
Compile::extscalar: n=n/2 cannot be compiled and will be evaluated externally. The result is assumed to be of type Real. >>
Why? n = Length[{1, 2, 3, 4}]
already make sure that n is integer, Why n=n/2 cannot be compiled?
Round
works $\endgroup$