aboutsummaryrefslogtreecommitdiff
path: root/src/float.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-11-01 23:15:11 +0000
committerMike Buland <eichlan@xagasoft.com>2010-11-01 23:15:11 +0000
commit2cd1a89109651a19138aec9988d765208d7709e5 (patch)
tree66ea6d6e379c82f17993f9e398999b820d9f2251 /src/float.cpp
parent1035f576164ceb50f85b787459ad760e0ac7b2b9 (diff)
downloadlibgats-2cd1a89109651a19138aec9988d765208d7709e5.tar.gz
libgats-2cd1a89109651a19138aec9988d765208d7709e5.tar.bz2
libgats-2cd1a89109651a19138aec9988d765208d7709e5.tar.xz
libgats-2cd1a89109651a19138aec9988d765208d7709e5.zip
Minor changes to the float that may circumvent some stupidness in the mingwrt
snprintf code. I really need to write my own number parser/writer.
Diffstat (limited to 'src/float.cpp')
-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