aboutsummaryrefslogtreecommitdiff
path: root/src/float.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/float.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/float.cpp b/src/float.cpp
index 139df3e..e85dff8 100644
--- a/src/float.cpp
+++ b/src/float.cpp
@@ -19,21 +19,28 @@ Gats::Float::~Float()
19 19
20void Gats::Float::write( Bu::Stream &rOut ) const 20void Gats::Float::write( Bu::Stream &rOut ) const
21{ 21{
22 char buf[50]; 22 if( sWriteCache.isEmpty() )
23 23 {
24 int iSize = snprintf( buf, 50, "%la", fVal ); 24 char buf[50];
25 25
26 int iSize = snprintf( buf, 50, "%la", fVal );
27 sWriteCache.set( buf, iSize );
28 }
26 rOut.write("f", 1 ); 29 rOut.write("f", 1 );
27 Gats::Integer::writePackedInt( rOut, iSize ); 30 Gats::Integer::writePackedInt( rOut, sWriteCache.getSize() );
28 rOut.write( buf, iSize ); 31 rOut.write( sWriteCache.getStr(), sWriteCache.getSize() );
29} 32}
30 33
34#include <bu/sio.h>
35using namespace Bu;
36
31void Gats::Float::read( Bu::Stream &rIn, char cType ) 37void Gats::Float::read( Bu::Stream &rIn, char cType )
32{ 38{
33 int iSize; 39 int iSize;
34 Gats::Integer::readPackedInt( rIn, iSize ); 40 Gats::Integer::readPackedInt( rIn, iSize );
35 char buf[50]; 41 char buf[50];
36 rIn.read( buf, iSize ); 42 buf[rIn.read( buf, iSize )] = '\0';
43 sio << "Reading float, iSize = " << iSize << ", str = " << buf << sio.nl;
37 sscanf( buf, "%la", &fVal ); 44 sscanf( buf, "%la", &fVal );
38} 45}
39 46