Your question is not limited to EJS. It is a general question related to mathematics and programming.

3?log[sub]10[/sub](x)<4 if 10002?log[sub]10[/sub](x)<3 if 100
However, java did not provide function for log[sub]10[/sub](x).
It only provide nature log, i.e. ln(x).
log[sub]10[/sub](x)= log[sub]e[/sub](x)/log[sub]e[/sub](10)

and Math.pow(a,b) will return a[sup]b[/sup]

The following formula should give you what you want.
[code]y=(int)(Math.pow(10,(int)(Math.log(x)/Math.log(10.)+1.e-8)));[/code]
1.e-8 was added due to possible numerical error.