This question already has answers here:
working with incredibly large numbers in .NET
(11 answers)
Closed 5 years ago.
I have to be able to handle extreme numbers and large es: consisting of eight million bits, but with which I must be able to perform the operations of division and rest.
This number can also be used as an array of bool
Use a BigInteger
The BigInteger type is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds.
Related
This question already has answers here:
Convert integer to binary in C#
(22 answers)
C# convert int to string with padding zeros?
(15 answers)
Closed 2 days ago.
I have a data I'm getting using my form and then I need to send it to a different software as an 8 digits number (in binary) the problem is the zeroes that come before the first '1' to appear in the data disappear.
for example:
the number 3 in binary is 00000011 so what will be send is 11
the letter A in binary is 01000001 so what will be send is 1000001
I need a code that will recognize how many digits in my data and add zeroes in front until the number would be 8 digits in c#
I looked online but all I could find is adding two known integers together but since I don't know how many digits would be missing from my data (as I don't know what the data would be yet, depends on the user), I can't use that.
This question already has answers here:
Casting to byte in C# [duplicate]
(5 answers)
Closed 3 months ago.
When it converts to int implicitly - the result is obvious, but when it adds bytes - it`s different, why?
Your code just overflows byte — it supports integer values from 0 to 255. You should use at least short.
This question already has answers here:
Is C#/.NET signed integer overflow behavior defined?
(2 answers)
Closed 4 months ago.
I just had an idea to make a program that creates amount of random numbers until the certain number is gotten and then prints that amount. So I got a negative number a few times, how is that possible? my code and its output example
The random call line 5 is hidden but it can be negative you should read the doc and change the call so it return only positive integers.
This question already has answers here:
How do I find the size of a 2D array? [duplicate]
(3 answers)
Closed 6 years ago.
I have a vector: int[,] leg = new int[100, 2]; and I put some numbers in it. Is there a function beside v.Length that shows how many numbers I put in my vector?(v.Length shows me that I have 200 numbers which is wrong because I put in just a few)
What you have is a 2-dimensional array. The Length property reports its size, which is fixed over its lifetime. When you create an array, the members are default initialized; in the case of an int array everything is set to 0. What you seem to be asking about is how many elements you have written to. This is not tracked anywhere. You could either count every time you assign to an element or count the non-zero elements. Note that these measure different things and could give different answers.
This question already has answers here:
How can I convert an integer into its verbal representation?
(16 answers)
.NET convert number to string representation (1 to one, 2 to two, etc...)
(11 answers)
Closed 8 years ago.
Hey anyone know about a function in C# that converts numerical value in to words
Like If I give Input: 53904
Then the output should be: FIFTY THREE THOUSAND NINE HUNDRED FOUR ONLY
By far, the best solution for this is the .NET Humanizr. It installs a series of extension methods and you can use it just like this:
15.ToWords(); // Returns "Fifteen"
int i;
i = 1587;
i.ToWords(); // Returns "One Thousand Five Hundred and Eighty Seven"
This works not only for numbers, but it works on DateTime, TimeSpan, Enums and others. I have used it in one of projects and it works great!
In addition, it has several other language translations, so it'll work in other languages, if you need it to.