Invalid double value '2.454' for locale 'en_CA'

So exit Convert.ToDouble does this

I think the exception is coming from RTL2 code, it matches the formatexception.

On Toffee ToDouble calls TryParseNumber and thats what I copied . I have to run on the watch because I cant repro on my mac. Its also the binary you ship.

If I fix it a bit

      var Formatter := new NSNumberFormatter;
      Formatter.numberStyle := NSNumberFormatterStyle.NSNumberFormatterDecimalStyle;
      Formatter.locale := new NSLocale withLocaleIdentifier('en_CA');
      result := Formatter.numberFromString(value).doubleValue;

This code works.

I think its something about NSRange on the device. Even if i dont use the passed in string i return odd vales in location

This does sound a bitness bug for arm64_32, yeah. can you do me a favor and run the following code for watchOS simulator, watchOS device as armv7k and watchOS arm64_32? And can you also enable the “Generate IR” option, and zip up[ and post the generated .ll for all architectures (just zip up the entire ./bin folder for the lib)?

      NSLog("ProcessArchitecture %@", Environment.ProcessArchitecture);
      NSLog("ProcessBitness %d", Environment.ProcessBitness);
      NSLog("OSArchitecture %@", Environment.OSArchitecture);
      NSLog("OSBitness %d", Environment.OSBitness);
      var aValue: NSString := "2.454";
      var aLocation := (aValue as PlatformString).rangeOfCharacterFromSet(NSCharacterSet.whitespaceAndNewlineCharacterSet).location;
      NSLog("aLocation %ld", aLocation);
      NSLog("NSNotFound %ld", NSNotFound);
      NSLog("!=? %d", aLocation ≠ NSNotFound);

      NSLog("aLocation %@", Convert.ToHexString(aLocation));
      NSLog("NSNotFound %@", Convert.ToHexString(NSNotFound));

fwiw, i get this on macOS arm64

2022-01-18 18:05:00.228580-0400 ConsoleApplication25[48243:693126] ProcessArchitecture arm64
2022-01-18 18:05:00.228950-0400 ConsoleApplication25[48243:693126] ProcessBitness 64
2022-01-18 18:05:00.228965-0400 ConsoleApplication25[48243:693126] OSArchitecture arm64
2022-01-18 18:05:00.229047-0400 ConsoleApplication25[48243:693126] OSBitness 64
2022-01-18 18:05:00.229194-0400 ConsoleApplication25[48243:693126] aLocation 9223372036854775807
2022-01-18 18:05:00.229225-0400 ConsoleApplication25[48243:693126] NSNotFound 9223372036854775807
2022-01-18 18:05:00.229245-0400 ConsoleApplication25[48243:693126] !=? 0
2022-01-18 18:05:00.229482-0400 ConsoleApplication25[48243:693126] aLocation 7FFFFFFFFFFFFFFF
2022-01-18 18:05:00.229560-0400 ConsoleApplication25[48243:693126] NSNotFound 7FFFFFFFFFFFFFFF

Logged as bugs://E25638.

What did you mean by running the watchOS device as armv7k and arm64_32 ?

I ran the code in the simulator and got

2022-01-19 08:18:43.875169-0500 MyWatchApp WatchKit Extension[14540:4111680] ProcessArchitecture armv7k
2022-01-19 08:18:43.875337-0500 MyWatchApp WatchKit Extension[14540:4111680] ProcessBitness 64
2022-01-19 08:18:43.875524-0500 MyWatchApp WatchKit Extension[14540:4111680] OSArchitecture armv7k
2022-01-19 08:18:43.875632-0500 MyWatchApp WatchKit Extension[14540:4111680] OSBitness 64
2022-01-19 08:18:43.875719-0500 MyWatchApp WatchKit Extension[14540:4111680] aLocation 9223372036854775807
2022-01-19 08:18:43.875776-0500 MyWatchApp WatchKit Extension[14540:4111680] NSNotFound 9223372036854775807
2022-01-19 08:18:43.875904-0500 MyWatchApp WatchKit Extension[14540:4111680] !=? 0
2022-01-19 08:18:43.876282-0500 MyWatchApp WatchKit Extension[14540:4111680] aLocation 7FFFFFFFFFFFFFFF
2022-01-19 08:18:43.876394-0500 MyWatchApp WatchKit Extension[14540:4111680] NSNotFound 7FFFFFFFFFFFFFFF

and on my watch and got

2022-01-19 08:32:06.394903-0500 MyWatchApp WatchKit Extension[928:980382] ProcessArchitecture arm64_32
2022-01-19 08:32:06.395104-0500 MyWatchApp WatchKit Extension[928:980382] ProcessBitness 32
2022-01-19 08:32:06.395192-0500 MyWatchApp WatchKit Extension[928:980382] OSArchitecture arm64_32
2022-01-19 08:32:06.395267-0500 MyWatchApp WatchKit Extension[928:980382] OSBitness 32
2022-01-19 08:32:06.395351-0500 MyWatchApp WatchKit Extension[928:980382] aLocation 705803600
2022-01-19 08:32:06.395420-0500 MyWatchApp WatchKit Extension[928:980382] NSNotFound 2147483647
2022-01-19 08:32:06.395489-0500 MyWatchApp WatchKit Extension[928:980382] !=? 1
2022-01-19 08:32:06.397441-0500 MyWatchApp WatchKit Extension[928:980382] aLocation 2A11B550
2022-01-19 08:32:06.397816-0500 MyWatchApp WatchKit Extension[928:980382] NSNotFound 7FFFFFFF

The generate ir option seem exposed in a multi target project is this ok ?

  <PropertyGroup Condition=" '$(Target)' == 'Toffee.watchOS' ">
  </PropertyGroup> (689.0 KB)

Like iOS and macOS, watchOS supports two architectures, the older pure 32-bit armv7k, and the newer “mostly” 64-bit arm64_32.

thanx. definitely something going wrong here…

Should be fine, yes. thanx!

I’m gonna run a new SDK import for you. what version of Xcode/watchOS do you need, to build against?

watch os 8.3 and xcode 13.2.1

1 Like

Should be fixed (compiler-side) for vNext. thanx!


1 Like

I tried with the lines of code above and that worked but my library gives me a slightly different message

WatchKit Extension[1031:1257100] *** Terminating app due to uncaught exception ‘Exception’, reason: 'Invalid double value ‘1.28’ for locale '

It’s calling into JsonDeserializer and eventually calling Convert.ToDouble. When you said should be fixed compiler side are there other things I need ?

No, there shouldn’t. But that said, the fix was of cousre as yet untested. Does your standaalone test case still fail, too? ie

var aValue: NSString := "2.454";
      var aLocation := (aValue as PlatformString).rangeOfCharacterFromSet(NSCharacterSet.whitespaceAndNewlineCharacterSet).location;
      NSLog("aLocation %ld", aLocation);
      NSLog("NSNotFound %ld", NSNotFound);


Oh, actually the build you grabed mighty not have bneen a full rebuiltd, and thus not have RTL2 rebuilt with the latest compiler. i’ll initiate a full rebuild.

1 Like

Is the full build still running ?

Yeah, sorry, I ran into some other issues exposed by the rebuild due to unrelated compiler changes from earlier in the week. (it got more stricter with mixing Island and Cocoa objects in generics). Glad I ran into those today, and not on full rebuild day tomorrow :joy:.

the build thats running now has been long enough so I think it got past any such issues, and shod succeeded in about 30m or so.

1 Like

Up now.

1 Like

Thanks very much it works now on my watch.

1 Like


bugs://E25638 was closed as fixed.