Questions tagged [ulong]

65 questions
1
vote
0 answers

Using ulong with Math.Pow

I have the following code: ulong num = ulong.Parse(Console.ReadLine()); ulong num1 = Math.Pow(num, 2); This gives me the following error: Error CS0266 Cannot implicitly convert type 'double' to 'ulong'. An explicit conversion exists (are you…
1
vote
2 answers

Why is this returning 0? It should output 18446744073709551615, which should fit

This code returns 0, where it should return 18446744073709551615, which should fit in a ulong? When I set it to iterate 63 (rather than 64) times I get 9223372036854775808, which is correct. public static ulong Total() { ulong output = 1ul ; …
SamWhyte
  • 19
  • 1
1
vote
2 answers

OpenCL : How to have access from a uint4 (or ulong[2]) to each 16 uchar values?

I have 16 indexes going from 0 to 255 (8 bits each) stored in a big uint4 and another into a ulong[2]. How can I convert them so I can have access to each of their individual 8-bit (uchar) values? right now I'm doing convertion like this for…
Jean F.
  • 127
  • 8
1
vote
1 answer

bitwise negation operator for ulong returns uint

I want to remove the last set bit of a ulong. Here's what I do: ulong mydata; ... ulong t = 1; for (int i = 0; i < ulongSizeBits; i++) { if ((myData&t)!=0) { mydata = mydata & (~t); break; } t <<= 1; } The problem…
Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224
1
vote
2 answers

fast binary digit counter 64bits numbers c#

I try to find a solution of this everywhere. My Request is to find a very fast algorithm code in order to get the number of digits in a binary representation of a unsigned 64bit integrer (ulong). For example: 127 = 7 binary digits. 153 = 8 binary…
Ignacio Bustos
  • 1,415
  • 2
  • 17
  • 26
1
vote
4 answers

C# - Convert to string the significant part from a hex/ulong value

How can I take as a string the significant part of a hex/ulong number? For example, if I have 0x00000321321, I want to get "321321". If I try something like: ulong x = 0x0000023632763; string s = x.toString(); I get 593700707, so it is not what i…
darkdante
  • 707
  • 1
  • 17
  • 36
0
votes
0 answers

ulong is not be stored correctly in LiteDatabse

I am now making a MMO game using Unity. Also I am using the LiteDB to store users data. UserModel looks like this. Everything is working correctly except for the mUserOwnerClientId. The variable type is ulong and I tried to store…
James
  • 1
  • 2
0
votes
1 answer

C# How to represent (unsigned long)(unsigned int) (ulong)(uint) with XOR (^)

I'm converting C++ code to C# Say I got this in C++ int v5; v5 = (*(_DWORD *)(v4 + 68) ^ (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 56) ^ *(_DWORD *)(v4 + 20))) % 9; In C# it would be like.. int v5; v5 = (int)((BitConverter.ToInt32(v4,…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
0
votes
1 answer

How to put a ULong to a ByteBuffer in Kotlin

I just the answer in this post How to convert a Data Class to ByteBuffer in Kotlin? And it works as expected. The problem is that nearly all data types are possible to put except the unsigned once. There are putLong etc. functions for bytebuffers…
abeat
  • 31
  • 2
0
votes
1 answer

Chess BitBoards in kotlin. Which datatype?

i think this question has not been asked yet. Thing is, in chess we use bitboards to speed move-generation-cycles up by representing a position by a bit=1 and other by a bit=0. In chess we have 8*8 positions. In combination with modern cpus its…
Plagueis
  • 173
  • 1
  • 3
  • 12
0
votes
1 answer

Why does (ULONG_PTR)x > (ULONG_PTR)y comparison fail?

0x8A81FAA is less then 0x7FFFFFF0000 so why is it true? #if defined(_X86_) #define ProbeForReadUnicodeStringFullBuffer(String) \ if (((ULONG_PTR)((String).Buffer) & (sizeof(BYTE) - 1))…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
0
votes
2 answers

How can I accept a ulong type variable in C#?

How can we take input of a ulong type variable in C#? if we use Console.ReadLine() then how to convert string to ulong ?
sassygirl
  • 1
  • 1
0
votes
1 answer

How to parse long.MaxValue and ulong.MaxValue when doing conversion

I have tried to parse the maxvalue of long and ulong but it fails. How to do that? Int64.TryParse(value.ToString(), out resultInt) value is Int64.MaxValue but the type of the value is double.
Durga S
  • 285
  • 1
  • 8
0
votes
1 answer

What is a better way to pack 4 ints into ulong?

I need to pack several int values(each value only ranging from 0 to 999) into ulong. I have a working method like below but can it be optimized? I know it hurts your eyes with lots of 0's, sorry. public class Test { public void Start() { …
Elonoa
  • 467
  • 7
  • 19
0
votes
1 answer

Why does this ulong divided by ulong give me 0?

I am grabbing total RAM of a computer system and available RAM and trying to work out what percentage is available. I am using the following code: double percent = my.Info.AvailablePhysicalMemory / my.Info.TotalPhysicalMemory; and have also…
SystemX17
  • 3,637
  • 4
  • 25
  • 36