[TIMOB-3002] iOS: Ti.UI.createLabel with text set as value of 0.07 gives 0.07000000000001
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2017-07-10T21:44:09.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | api |
Reporter | lordsiris |
Assignee | Ingo Muschenetz |
Created | 2011-04-15T03:34:27.000+0000 |
Updated | 2017-07-10T21:44:09.000+0000 |
Description
currentValue = 0.07;
var currentReadingValueLabel = Ti.UI.createLabel({
text: currentValue,
left: 110,
top: 22,
height: 'auto',
color: '#fff',
width: 150,
textAlign: 'left',
font:{
fontSize: 24,
fontStyle: 'bold'
}
});
When displayed in both the iphone simulator and on the device (iPhone 3GS, iOS 4.1) I don't get just 0.07 but something like 0.07000000000001. Using Dev 1.2.2 with iOS SDK 4.2 and Titanium Mobile 1.5.1 (latest).
Maybe this is just an issue with javascript decimal fraction precision, but it's not clear since no arithmetic functions are being applied. Worked around the issue with currentValue = currentValue.toString();.
Confirmed SDK 2.2.0.014b86f. This is probably a rounding error due to us using 32-bit float instead of 64-bit.
I am unable to reproduce this issue with the following environment; iPhone 6 (10.0) Studio 4.9.0.201705302345 Ti SDK 6.1.1 GA Appc NPM 4.2.9 Appc CLI 6.2.2 Ti CLI 5.0.14 Alloy 1.9.11 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131