home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-05-18 | 592 b | 33 lines | [TEXT/CWIE] |
- //Copyright (c) 1997 Aidan Cully
- //All rights reserved
-
- #include <QuickDraw.h>
- #include "Misc.h"
- #include "CLStrStuff.h"
-
- unsigned char *gcvt( float num, int precision ) {
- int temp;
- Str32 buf;
-
- if( num < 0 ) {
- StrCpy( buf, "\p-" );
- num = -num;
- } else
- buf[0] = 0;
- StrCat( buf, IToA( (int)num ) );
- StrCat( buf, "\p." );
- temp = precision-buf[0];
- while( temp-- ) {
- num -= (int)num;
- num *= 10;
- if( !(int)num )
- StrCat( buf, "\p0" );
- else
- StrCat( buf, IToA( (int)num ) );
- }
- while( buf[buf[0]] == '0' )
- buf[0]--;
- if( buf[buf[0]] == '.' )
- buf[0]--;
- return( buf );
- }