Path: utzoo!censor!geac!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ames!aplvax!acf4!lixj From: lixj@acf4.NYU.EDU (Xiaojian Li) Newsgroups: comp.lang.perl Subject: Slower in numerical calculation than awk? Message-ID: <2540004@acf4.NYU.EDU> Date: 4 Feb 91 08:46:00 GMT Organization: New York University Lines: 26 To: rnews@cmcl2.NYU.EDU, rosenblg@acf4.NYU.EDU I write small awk and perl program, and to my dismay, awk is almost twice as fast as perl, ---awk--- #!/bin/awk -f BEGIN { x = 1.0 for(i=0;i<100000;++i) x += i } END { print x } 4.99995e+09 5.6u 0.0s 0:05 100% 0+280k 0+0io 0pf+0w ---perl--- Both are run on SPARC 1 #!/usr/local/bin/perl $X = 1.0; for ($i = 0; $i < 100000; ++$i) { $X += $i; } print $X, "\n"; 4999950001 10.6u 0.1s 0:10 100% 0+428k 0+0io 0pf+0w I notice that perl gives more accurate result. Is this higher precision which causes slowing down? In what precision perls does math?