Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Char < operator not working #31

Closed
fanoI opened this issue Jan 1, 2018 · 1 comment
Closed

Char < operator not working #31

fanoI opened this issue Jan 1, 2018 · 1 comment

Comments

@fanoI
Copy link
Contributor

fanoI commented Jan 1, 2018

Trying to do this code on a char when the value interpreted as number (the codepoint) is > SHORT_MAX this tests fails:

       private byte GetByte(char ch)
        {
            /* ch is in reality an ASCII character? */
            //if (ch >= 0 && ch < 127)
            if (ch < 127)
            {
                //mDebugger.SendInternal($"ch {(ushort)ch} is ASCII");
                return (byte)ch;
            }

	   return 42;
}

For the same cause Char.IsSurrugate(ch) returns false.

This the IL that this code generates:

GetByte:
IL_0000:  nop         
IL_0001:  ldarg.1     
IL_0002:  ldc.i4.s    7F
IL_0004:  clt         
IL_0006:  stloc.0     
IL_0007:  ldloc.0     
IL_0008:  brfalse.s   IL_0010
IL_000A:  nop         
IL_000B:  ldarg.1     
IL_000C:  conv.u1     
IL_000D:  stloc.1     
IL_000E:  br.s        IL_0015
IL_0010:  ldc.i4.s    2A 
IL_0012:  stloc.1     
IL_0013:  br.s        IL_0015
IL_0015:  ldloc.1     
IL_0016:  ret         
@fanoI
Copy link
Contributor Author

fanoI commented Jan 1, 2018

Fixed by #18

@fanoI fanoI closed this as completed Jan 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant