Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32238 loss of precision set double #79

Merged
merged 1 commit into from
Jun 13, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions android/titanium/src/org/appcelerator/titanium/TiProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,24 @@ public double getDouble(String key, double def)
if (DBG) {
Log.d(LCAT,"getDouble called with key:"+key+", def:"+def);
}
return (double)preferences.getFloat(key,(float)def);
if( !this.hasProperty(key) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally use spaces after if , and none inside the condition, but I'll update this when I merge

return def;

String stringValue = preferences.getString(key,"");
try {
return Double.parseDouble(stringValue);
} catch (NumberFormatException e) {
return def;
}
}
public void setDouble(String key, double value)
{
if (DBG) {
Log.d(LCAT,"setDouble called with key:"+key+", value:"+value);
}

SharedPreferences.Editor editor = preferences.edit();
editor.putFloat(key,(float)value);
editor.putString(key,value + "");
editor.commit();
}
public boolean getBool(String key, boolean def)
Expand Down