Ghost, here's a softball for ya.
- From: Jeff…Relf <Jeff_Relf@xxxxxxxxx>
- Date: 7 Jun 2007 15:40:24 GMT
Here's a softball for ya Ghost...
#include <StdIO.H>
typedef wchar_t * LnP ;
#define Str swprintf
#define LoopTil( StopCond ) Ch = 1, P -- ; \
while ( \
Ch \
&& ! ( Ch = * ++ P, Ch2 = ! Ch ? 0 : P [ 1 ], StopCond ) )
// Shows the first three significant figures
// with or without a comma and/or a dot.
// Removes extraneous zeros on the left or right.
LnP Prn( float X ) { static int I ; static wchar_t B_[ 9 ][ 20 ];
LnP B = B_[ I ++ , I %= 9 ];
Str( B, L"%.3f", X ); if ( * B == '0' ) B ++ ;
LnP P = B ; wchar_t Ch, Ch2 ; int FromLeft = 0, Found_Dot = 0 ;
LoopTil( FromLeft >= 3 && Found_Dot ) {
int Dot = Ch == '.' ; Found_Dot |= Dot ;
if ( ! Dot ) FromLeft ++ ; }
main() { LnP P ; // Single Step in Debugger to see results.
P = Prn( 0 ); // . <-- I prefer this over " 0 ".
P = Prn( .0055 ); // .006 ideally, this'd print " 5.5 milli "
P = Prn( 1.1 ); // 1.1
P = Prn( 10 ); // 10
P = Prn( 21.1 ); // 21.1
P = Prn( 3000 ); // 3,000 ideally, this'd print " 3 kilo "
P = Prn( 4000.6789 ); // 4,000 ideally, this'd print " 4 kilo "
}
Prn() is used to produce reports like
X's list of the " Richest/Poorest Players ", to wit:
" www.Cotse.NET/users/jeffrelf/Phy_R.TXT ".
Speaking of which, I recently changed the scoring to:
" Virtual_Cash / Post / Day " instead of " Virtual_Cash / Post ".
When scoring, multiple crossposts count as multiple posts
and the Age of a player's set of posts is never less than 1.
Some of X's QuickSorts compare multiple floating point fields, to wit:
" float Cmp() " in " www.Cotse.NET/users/jeffrelf/X.CPP ".
.
- Follow-Ups:
- Re: Ghost, here's a softball for ya.
- From: The Ghost In The Machine
- Re: Ghost, here's a softball for ya.
- References:
- Re: X.EXE's " Power Rating "
- From: Peter Köhlmann
- Re: Usenet Über Alles !
- From: The Ghost In The Machine
- Re: X.EXE's " Power Rating "
- Prev by Date: Re: Richard Dawkins
- Next by Date: "The Nature of Mass"
- Previous by thread: Re: Usenet Über Alles !
- Next by thread: Re: Ghost, here's a softball for ya.
- Index(es):