KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
You can do >, <, ==, etc. comparisons between sbyte and byte, int, uint, short, ushort, long, double, and float. But not ulong. My brain is exploding. Can anyone explain why sbyte can be compared to uint but not ulong? public bool sbyte_ulong_compare(sbyte x, ulong y) { return x < y; // compiler error CS0019 } Also, using unchecked doesn't make things work any better. Brain melting. Another edit. This works: public bool sbyte_ulong_compare(sbyte x, ulong y) { // // returns x < y // if (x < 0) return true; if (y > 127) return true; return ((long)x < (long)y); }
Tags (comma-separated)
Save Edits
Cancel