in reply to perl to protoype algorithms

To answer your question, prototype and test the algorithm in as many languages as you are willing to debug. Personally, I'd prototype in whatever language I was going to implement in. While good algorithms are language agnostic, debugging is not. If you use a good algorithm, it will look mostly the same regardless of whether you write the code in C, Perl or Java - but there will be differences in implementation (like casting in a strongly typed language).

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

    There's a place called JavaJunkies - Wow! Thanks for the link!

    Tongue firmly in cheek