Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

ToFloat() can convert from integers #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,14 @@ class JSON
double ToFloat() const { bool b; return ToFloat( b ); }
double ToFloat( bool &ok ) const {
ok = (Type == Class::Floating);
return ok ? Internal.Float : 0.0;
if (ok)
return Internal.Float;

ok = (Type == Class::Integral);
if (ok)
return Internal.Int;

return 0.0;
}

long ToInt() const { bool b; return ToInt( b ); }
Expand Down Expand Up @@ -372,7 +379,7 @@ class JSON
default:
return "";
}
return "";
//return "";
}

friend std::ostream& operator<<( std::ostream&, const JSON & );
Expand Down