#include "util.h" void printLongDc( long val, long m, short sign, char *trg) { int ct; long vrest,v,dv; ct = 0; vrest = val; if(vrest < 0 ){ vrest = vrest * -1; if(sign){ trg[ct] = '-'; ct++; } } else { if(sign){ trg[ct] = '+'; ct++; } } dv = m; while( dv > 1 ) { trg[ct] = '0'; if(vrest >= dv ){ v = vrest / dv; vrest = vrest - (v * dv); trg[ct] = (unsigned char)v + 0x30; } dv = dv / 10; ct++; } trg[ct] = '0'; if(vrest > 0 ){ trg[ct] = (unsigned char)(vrest + 0x30); } ct++; trg[ct] = 0; } void printShortDc( short val, short m, short sign, char *trg) { short ct,vrest,v,dv; ct = 0; vrest = val; if(vrest < 0 ){ vrest = vrest * -1; if(sign){ trg[ct] = '-'; ct++; } } else { if(sign){ trg[ct] = '+'; ct++; } } dv = m; while( dv > 1 ) { trg[ct] = '0'; if(vrest >= dv ){ v = vrest / dv; vrest = vrest - (v * dv); trg[ct] = (unsigned char)v + 0x30; } dv = dv / 10; ct++; } trg[ct] = '0'; if(vrest > 0 ){ trg[ct] = (unsigned char)(vrest + 0x30); } ct++; trg[ct] = 0; } void printArcStr( double arc, int hours, char *trg ) { double d,t,m,s,v; short _d,_m,_s; v = arc; if( hours ) { v = arc / 15.0; } modf( v / 3600 , &d ); t = d * 3600; v = v - t; modf( v / 60 , &m ); t = m * 60; modf( v - t , &s); if(m < 0 ){ m = m * -1; } if(s < 0 ){ s = s * -1; } _d = (short)d; _m = (short)m; _s = (short)s; printShortDc(_d,100,1,&trg[0]); trg[4] = ':'; printShortDc(_m,10,0,&trg[5]); trg[7] = ':'; printShortDc(_s,10,0,&trg[8]); /* sprintf(trg,"%03.f:%02.f:%02.f\0", (float)d, (float)m, (float)s);*/ }