Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!ucdavis!schell From: schell@birch.eecs.ucdavis.edu (Stephan Schell) Newsgroups: comp.sys.next Subject: problem with sprintf using "%e" format Message-ID: Date: 15 May 91 05:03:49 GMT Sender: usenet@ucdavis.ucdavis.edu Distribution: comp Organization: University of California at Davis Lines: 48 I am having a problem with code that calls sprintf(buf, "%e", a_double_val). In particular, the results are fine but the execution time is way too high. I wrote a little program: #include #include main() { char buf[80]; struct tms t0, t1; int i, N; printf("Enter number of items: "); scanf("%d", &N); times( &t0 ); for ( i = 0; i < N; i++ ) sprintf(buf, "%e\n", 3.1415926535897 ); times( &t1 ); printf("CPU seconds %e\n", (t1.tms_utime - t0.tms_utime) * CLK_FAC ); printf("SYS seconds %e\n", (t1.tms_stime - t0.tms_stime) * CLK_FAC ); exit(0); } For N = 100000, the results on several different machines are: NeXT HP 9000/835 DECstation 5000/200 CPU 5.7 12.6 4.2 SYS 684.2 0.03 0.07 For reference, CLK_FAC is 1/60 on the NeXT and the DEC, and 1/100 on the HP. GCC and cc on the DEC yielded the same results. WHY IS THE SYS TIME ON THE NEXT SO LARGE? ARGGGHHHH! I tracked it down as far as I could, to the ecvt routine on the NeXT. Other floating point stuff seems to run quite fast. The NeXT in question is an older Cube that has been upgraded to an 040 and 2.0 or 2.1. Is this NeXT messed up in its ecvt routine or are all NeXTs messed up this way? Why is ecvt considered (or using) a system call? Am I completely missing something here? Thanks, Steve -- ------------------------------------------------------------------------------- Dr. Stephan Schell schell@llandru.eecs.ucdavis.edu Dept. of Electrical Engineering {ucbvax,lll-crg}!ucdavis!llandru!schell & Compter Science University of California, Davis (916) 752-1326