Overflow, carry, etc i C#
-
Hi all! Is there a way of checking overflow, carry, etc on integer arithmetic in C#? I'm an old assembler programmer and I sometimes would like this funtionality when performing bitwise operations on integer variables. Also, I would like to see ROL and ROR (rotate left, rotate right). Do these exist in C#? For performance reasons, implementing a class realizing this is not an option. Thank you.
-
Hi all! Is there a way of checking overflow, carry, etc on integer arithmetic in C#? I'm an old assembler programmer and I sometimes would like this funtionality when performing bitwise operations on integer variables. Also, I would like to see ROL and ROR (rotate left, rotate right). Do these exist in C#? For performance reasons, implementing a class realizing this is not an option. Thank you.
See Arithmetic Exceptions[^].
ROL
andROR
are not part of the language, you would need to write your own versions.hanzibal2 wrote:
For performance reasons, implementing a class realizing this is not an option.
If you are worried about performance then you should not be using C#.
Use the best guess
-
See Arithmetic Exceptions[^].
ROL
andROR
are not part of the language, you would need to write your own versions.hanzibal2 wrote:
For performance reasons, implementing a class realizing this is not an option.
If you are worried about performance then you should not be using C#.
Use the best guess
Quote:
ROL and ROR are not part of the language
Although << and >> (as well as <<= and >>=) are equivalent to SHL and SHR if I remember my aseembly language correctly...
Jon CodeWrite
-
Quote:
ROL and ROR are not part of the language
Although << and >> (as well as <<= and >>=) are equivalent to SHL and SHR if I remember my aseembly language correctly...
Jon CodeWrite
-
See Arithmetic Exceptions[^].
ROL
andROR
are not part of the language, you would need to write your own versions.hanzibal2 wrote:
For performance reasons, implementing a class realizing this is not an option.
If you are worried about performance then you should not be using C#.
Use the best guess
Thank you for your answer. There are so many advantages with C# over almost any other language that I just can't live without and since C# is the language I chose for my project, why not write repetitive sections as effective as possible? You are correct, but you answered a question that I didn't ask ;-)
-
Thank you for your answer. There are so many advantages with C# over almost any other language that I just can't live without and since C# is the language I chose for my project, why not write repetitive sections as effective as possible? You are correct, but you answered a question that I didn't ask ;-)
-
Hi all! Is there a way of checking overflow, carry, etc on integer arithmetic in C#? I'm an old assembler programmer and I sometimes would like this funtionality when performing bitwise operations on integer variables. Also, I would like to see ROL and ROR (rotate left, rotate right). Do these exist in C#? For performance reasons, implementing a class realizing this is not an option. Thank you.
-