Bug 25458 - Incorrect float conversion
Summary: Incorrect float conversion
Status: RESOLVED DUPLICATE of bug 25487
Alias: None
Product: Mobile API (Preview)
Classification: Xamarin
Component: Xamarin.iOS ()
Version: Preview
Hardware: PC Windows
: --- major
Target Milestone: ---
Assignee: Eric Maupin
URL:
Depends on:
Blocks:
 
Reported: 2014-12-17 03:29 UTC by Mikalai
Modified: 2014-12-18 05:05 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Full sample solution (9.27 KB, application/zip)
2014-12-17 03:29 UTC, Mikalai
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 25487

Description Mikalai 2014-12-17 03:29:34 UTC
Created attachment 9097 [details]
Full sample solution

While testing Unified API for 64bit support for our iOS apps we're found this bug on 64bit devices. This works fine on 32bit devices

Sample code:
public override void ViewDidLoad ()
{
   base.ViewDidLoad ();

   LinearInterpolation (255, 0, 1);
}
   
public static Int32 LinearInterpolation(Int32 value1, Int32 value2, float amount)
{
   Int32 sub = value2 - value1;
   System.Diagnostics.Debug.WriteLine ("{0} - {1} = {2}", value2, value1, sub);
   float mult = sub * amount;
   System.Diagnostics.Debug.WriteLine ("{0} * {1} = {2:N6}",sub, amount, mult);
   var res = (Int32)(value1 + mult);
   System.Diagnostics.Debug.WriteLine ("(Int32)({0} + {1}) = {2}", value1, mult, res);
   return res;
}

Output (on iPhone 5s):
0 - 255 = -255
-255 * 1 = 4 294 967 000,000000
(Int32)(255 + 4,294967E+09) = -1

Output on iPad Mini:
0 - 255 = -255
-255 * 1 = -255,000000
(Int32)(255 + -255) = 0

Xamarin version info:
Xamarin Studio
Version 5.7 (build 652)
Installation UUID: 880a449a-2ad9-45d3-89e5-c224da8dca65
Runtime:
 Mono 3.12.0 ((detached/a813491)
 GTK+ 2.24.23 (Raleigh theme)

 Package version: 312000068

Apple Developer Tools
Xcode 6.1 (6604)
Build 6A1052d

Xamarin.iOS
Version: 8.6.0.32 (Enterprise Edition)
Hash: f31ad46
Branch: 
Build date: 2014-12-12 17:56:03-0500

Build Information
Release ID: 507000652
Git revision: 042e44ba92a6a9c46bd2b69b0b4348df43f381ea
Build date: 2014-12-11 18:37:24-05
Xamarin addins: 06d3aaafde7f726d508e079c9b297cc9aae4af55

Operating System
Mac OS X 10.10.0
Darwin Mac-mini-Admin.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 1 Glenn Wester 2014-12-17 13:35:01 UTC
Verified inconsistent output:

//iPhone6 iOS 8.1.2 physical 
0 - 255 = -255
-255 * 1 = 4,294,967,000.000000
(Int32)(255 + 4.294967E+09) = -1
2014-12-17 09:18:03.733 UnifiedTest[848:303719] Received memory warning.

//iPad iOS8.0.2 nicks physical
0 - 255 = -255
-255 * 1 = -255.000000
(Int32)(255 + -255) = 0

//iPad iOS 7.0.4 physical 
0 - 255 = -255
-255 * 1 = -255.000000
(Int32)(255 + -255) = 0

//iPhone4S 8.1.2 simulator
0 - 255 = -255
-255 * 1 = -255.000000
(Int32)(255 + -255) = 0
Comment 2 Rolf Bjarne Kvinge [MSFT] 2014-12-18 05:05:50 UTC

*** This bug has been marked as a duplicate of bug 25487 ***