Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 11985 [details]
Using the --aot-options=-O=float32, casting from nfloat to float does not work correctly. Also setting an nfloat variable with:
nfloat fromFloatConstant = 1f;
gives a value to fromFloatConstant of 5.26354424712089E-315
nfloat castFromDouble = (nfloat)1;
The reporting user noticed this when creating Vector2 types from UITouch objects. E.g.:
>var location = touch.LocationInView (touch.View);
>var position1 = new Vector2((float)location.X, (float)location.Y);
location.X and location.Y are of type nfloat. After this assignment position is (0, 0) no matter what location had for X and Y.
The following works correctly:
>var position2 = new Vector2((float)(double)location.X, (float)(double)location.Y);
## Steps to reproduce
1. Open the attached test project in Xamarin Studio and deploy app to a device.
2. Once app launches, note the console output showing the value for variable fromFloatConstant being 5.26354424712089E-315 instead of 1. Note also that casting the fromFloatConstant variable to a float explicitly before outputting shows the correct value.
3. Tap anywhere on the screen and look in the console output.
Expected result: position variable will match location variable.
Actual result: position variable shows as (0, 0)
In the console output after tapping you will also see that casting location.X and location.Y to a float before outputting shows the incorrect values of 0 for location.X and location.Y. I note this because it seemed odd to me that outputting an nfloat in Console.WriteLine showed the incorrect value when I set the nfloat variable from a float constant, but the _correct_ value if variable is converted to float before outputting, but in the case where the nfloat is assigned to an object by the runtime (getting the values from touch.LocationInView(touch.View) for instance) then the _incorrect_ value is output in Console.WriteLine if the nfloat is cast to float first, but the correct value is shown if I output location.X (an nfloat) directly using Console.WriteLine.
## My environment
=== Xamarin Studio ===
Version 5.9.4 (build 5)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Mono 4.0.2 ((detached/c99aa0c)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400020005
=== Xamarin.Android ===
Version: 220.127.116.11 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
=== Xamarin Android Player ===
Version: Unknown version
Location: /Applications/Xamarin Android Player.app
=== Apple Developer Tools ===
Xcode 6.4 (7720)
=== Xamarin.iOS ===
Version: 18.104.22.168 (Business Edition)
Build date: 2015-06-30 15:19:13-0400
=== Xamarin.Mac ===
Version: 22.214.171.124 (Business Edition)
=== Build Information ===
Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8
=== Operating System ===
Mac OS X 10.10.4
Darwin Jons-iMac.local 14.4.0 Darwin Kernel Version 14.4.0
Thu May 28 11:35:04 PDT 2015
Fixed in mono-extensions 2016a8bd3e898d37c84dfb810e7c8a4d1218bf29.
@Zoltan, is this something that can easily be backported to C5SR3 (the patch applies cleanly btw)?
I have checked this issue and observed that this issue is working fine with build attached in this card i.e. XI 126.96.36.1991
application output : https://gist.github.com/Mohit-Kheterpal/6336bd321a324ec2c96c
Hence closing this issue.
@Zoltan, I backported mono-extensions/2016a8bd3e898d37c84dfb810e7c8a4d1218bf29 to C5SR3, but that didn't fix it. Are there any other commits I need as well?
Committed another fix:
Author: Zoltan Varga <firstname.lastname@example.org>
Date: Fri Jul 17 16:04:26 2015 -0400
Bump mono-extensions to pick up ea6cf0888709074b3570cf7e22f3dc7873be4c09:
Author: Zoltan Varga <email@example.com>
Date: Fri Jul 17 16:00:59 2015 -0400
Fix nfloat->double conversions. Fixes #31846.