[comp.sys.mac.programmer] Can't Print Double Precision Floats

brianj@witsend.cs.umd.edu (Brian Johnson) (05/06/91)

I'm trying to print a double precision floating point value to Think
C's console window.  The number (usually around 3.xxe10) shows up fine
in the debugger, but I can't print it out.  I've tried every combination
of formatting options that I can think of.

My other problem is getting the square root of this value.  Can anyone
let me know how?  I've never used SANE, do I need to?

If someone could send me a couple of lines of working code to do these
things I'd be eternally grateful.

These don't work:
printf("SumSquared: %Le", (double) theData[0][LEAFNODE][SIZE].sumsquare);
printf("SumSquared: %Le", (float) theData[0][LEAFNODE][SIZE].sumsquare);
printf("SumSquared: %Lg", theData[0][LEAFNODE][SIZE].sumsquare);


---------------------------- Working code ------------------------------
typedef struct {
		short	number;
		double	sum;
		long	average;
		double	sumsquare;
		double	sd;		/* standard deviation */
		long	min;
		long	max;
	} VARIABLES;

printf("N:% d \t Sum:% ld \t Ave:% ld \t Min:% ld \t Max:% ld\n",
	theData[i][j][SIZE].number,
	(long) theData[i][j][k].sum,
	(long) theData[i][j][k].average,
	(long) theData[i][j][k].min,
	(long) theData[i][j][k].max);
---------------------------- Working code ------------------------------

--
Brian Johnson          Computer Science Department 
brianj@cs.umd.edu      University of Maryland  
(301) 405-2725         College Park, Md 20742