binary number represented in a long variable in c# -
in code having problem see in enumerator class binary format. know in c# have possibility represent hexadecimal 0xff (f.e.). know if have similar binary number like:
public static class myenum { public static const long tr = 000000001; public static const long trp = 000000010; ... } this enumerator represent 1, 2, 4, 8, ... type set inside. need binary number see easy number.
how can represent binary in c#?
i dont think there such representation in c#
from ecma script
9.4.4.2 integer literals integer literals used write values of types int, uint, long, , ulong. integer literals have 2 possible forms: decimal , hexadecimal.
also check .net compiler platform ("roslyn")
probably c# 6.0 add together feature
c# tries help introducing binary literal. let's start have:
var num1 = 1234; //1234 var num2 = 0x1234; //4660 what possible come now? here's answer:
var num3 = 0b1010; //10 of course of study binary digits becoming quite long fast. why nice separator has been introduced:
var num4 = 0b1100_1010; //202 there can many underscores possible. underscores can connected. , best thing: underscores work normal numbers , hex literals:
var num5 = 1_234_567_890; //123456789 var num6 = 0xff_fa_88_bc; //4294609084 var num7 = 0b10_01__01_10; //150 the constraint of underscore is, of course of study number cannot start it.
binary literals create enumerations , bit vectors little bit easier understand , handle. more close @ have been thinking when creating such constructs.
c# binary
No comments:
Post a Comment