You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Detailed repro steps so we can see the same problem
It's reproducible with all firmware that was compiled with SUPPORT_ANY_BASE_CONVERSION=ON.
E.g. Convert.ToInt16("1011110101001010", 2) should return -17078 because the MSB is set. But that return 0. It's caused by the native call to Convert::NativeToInt64. We shouldn't convert the 16bit base 2 string via strtoll. That results in the value 48458. After the check (result > maxValue || result < minValue) ? zero : result NativeToInt64 returns 0.
We have the same issue with ToInt32 and ToSByte.
With ToInt64 we have another issue:
long x1 = Convert.ToInt64("1100001001001011001001010101001100100000011011011111111111110011", 2);
long x2 = Convert.ToInt64("1411131125144033377763", 8);
long x3 = Convert.ToInt64("-4446419168141639693");
long x4 = Convert.ToInt64("C24B2553206DFFF3", 16);
All x values should be -4446419168141639693. But only x3 has this value. The other values are 9223372036854775807 which is not correct.
And last issue is Convert.ToUInt64 which is implemented in mscorlib with this call: return (ulong)NativeToInt64(value, true, 0, 0, fromBase);. Min and max value are set to 0 and second parameter signals a signed conversion. That can't work.
The text was updated successfully, but these errors were encountered:
Details about Problem
nanoFramework area: nanoCLR preview 1010 / mscorlib perview 73
Worked before? No
Detailed repro steps so we can see the same problem
It's reproducible with all firmware that was compiled with SUPPORT_ANY_BASE_CONVERSION=ON.
E.g.
Convert.ToInt16("1011110101001010", 2)
should return -17078 because the MSB is set. But that return 0. It's caused by the native call toConvert::NativeToInt64
. We shouldn't convert the 16bit base 2 string viastrtoll
. That results in the value 48458. After the check(result > maxValue || result < minValue) ? zero : result
NativeToInt64 returns 0.We have the same issue with ToInt32 and ToSByte.
With ToInt64 we have another issue:
All x values should be -4446419168141639693. But only x3 has this value. The other values are 9223372036854775807 which is not correct.
And last issue is Convert.ToUInt64 which is implemented in mscorlib with this call:
return (ulong)NativeToInt64(value, true, 0, 0, fromBase);
. Min and max value are set to 0 and second parameter signals a signed conversion. That can't work.The text was updated successfully, but these errors were encountered: