#include "gats/float.h" #include "gats/integer.h" #include Gats::Float::Float() : fVal( 0.0 ) { } Gats::Float::Float( double f ) : fVal( f ) { } Gats::Float::~Float() { } void Gats::Float::write( Bu::Stream &rOut ) const { if( sWriteCache.isEmpty() ) { char buf[50]; int iSize = snprintf( buf, 50, "%la", fVal ); sWriteCache.set( buf, iSize ); } rOut.write("f", 1 ); Gats::Integer::writePackedInt( rOut, sWriteCache.getSize() ); rOut.write( sWriteCache.getStr(), sWriteCache.getSize() ); } void Gats::Float::read( Bu::Stream &rIn, char cType ) { int iSize; Gats::Integer::readPackedInt( rIn, iSize ); char buf[50]; buf[rIn.read( buf, iSize )] = '\0'; sscanf( buf, "%la", &fVal ); } Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ) { return f << "(float) " << flt.getValue(); }