diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-08-19 06:28:17 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-08-19 06:28:17 +0000 |
commit | 11b5a91c5884d496744911f261ed6c2b053b9940 (patch) | |
tree | 61ed65f187e0719f141d80d4e1e648aeff311024 /src/float.cpp | |
parent | 9dc8cc535ef5fc4ea78f967fe285fe4424ff4458 (diff) | |
download | libgats-11b5a91c5884d496744911f261ed6c2b053b9940.tar.gz libgats-11b5a91c5884d496744911f261ed6c2b053b9940.tar.bz2 libgats-11b5a91c5884d496744911f261ed6c2b053b9940.tar.xz libgats-11b5a91c5884d496744911f261ed6c2b053b9940.zip |
Wow, it pretty much all works. the float format is a little funny, I treat it
as a string, with a string header and then string data that is then turned into
a float. It's pretty much how it's going to work, unless I come up with
something revolutionary.
Diffstat (limited to 'src/float.cpp')
-rw-r--r-- | src/float.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/float.cpp b/src/float.cpp index e69de29..e257b37 100644 --- a/src/float.cpp +++ b/src/float.cpp | |||
@@ -0,0 +1,37 @@ | |||
1 | #include "gats/float.h" | ||
2 | #include "gats/integer.h" | ||
3 | |||
4 | Gats::Float::Float() : | ||
5 | fVal( 0.0 ) | ||
6 | { | ||
7 | } | ||
8 | |||
9 | Gats::Float::Float( double f ) : | ||
10 | fVal( f ) | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Gats::Float::~Float() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | void Gats::Float::write( Bu::Stream &rOut ) const | ||
19 | { | ||
20 | char buf[50]; | ||
21 | |||
22 | int iSize = snprintf( buf, 50, "%la", fVal ); | ||
23 | |||
24 | rOut.write("f", 1 ); | ||
25 | Gats::Integer::writePackedInt( rOut, iSize ); | ||
26 | rOut.write( buf, iSize ); | ||
27 | } | ||
28 | |||
29 | void Gats::Float::read( Bu::Stream &rIn, char cType ) | ||
30 | { | ||
31 | int iSize; | ||
32 | Gats::Integer::readPackedInt( rIn, iSize ); | ||
33 | char buf[50]; | ||
34 | rIn.read( buf, iSize ); | ||
35 | sscanf( buf, "%la", &fVal ); | ||
36 | } | ||
37 | |||