in reply to perl to protoype algorithms
In your snippet, perl does exactly what I would expect - the algorithm is fine. It's the java implementation that fails.
Take a look at the following snippet, and see if it produces the results you expect with different values of w.
public class HelloWorld { public static void main(String[] args) { int w=Integer.parseInt(args[0]); System.out.println("No cast: " + Math.ceil (w / 24)); System.out.println("Divide, then cast: " + Math.ceil ((double) (w +/ 24))); System.out.println("Cast, then divide: " + Math.ceil ((double) w / + 24)); } }
Maybe this thread should be posted at http://javajunkies.org ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: perl to protoype algorithms
by BrowserUk (Patriarch) on Jun 12, 2002 at 22:25 UTC |