Added asDouble method to ZString.
This commit is contained in:
parent
beb3673241
commit
1cfdc23a57
@ -1,6 +1,7 @@
|
||||
#include "ZString.h"
|
||||
#include "Log.h"
|
||||
#include "Exception.h"
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace coreutils {
|
||||
@ -106,6 +107,10 @@ namespace coreutils {
|
||||
return tempInt;
|
||||
}
|
||||
|
||||
double ZString::asDouble() {
|
||||
return strtod(cursor, &cursor);
|
||||
}
|
||||
|
||||
int ZString::incrementCursor(int length) {
|
||||
char *temp = cursor;
|
||||
if((cursor + length) > (data + this->length))
|
||||
|
@ -128,6 +128,13 @@ namespace coreutils {
|
||||
|
||||
int asInteger();
|
||||
|
||||
///
|
||||
/// Return the floating point value of the ZString from the cursor to the first
|
||||
/// non-numeric character.
|
||||
///
|
||||
|
||||
double asDouble();
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
Binary file not shown.
Binary file not shown.
@ -4,6 +4,12 @@
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
// Test floating point reader.
|
||||
|
||||
coreutils::ZString pi("3.14159");
|
||||
double x = pi.asDouble();
|
||||
std::cout << "pi: " << x << std::endl;
|
||||
|
||||
// Test comparison operations.
|
||||
|
||||
coreutils::ZString test1("else");
|
||||
|
Loading…
x
Reference in New Issue
Block a user