Hey everyone,
I am using the RSA Algorithm for encryption/decryption, and in order to decrypt the files you have to deal with some pretty big values. More specifically, things like
P = C^d % n
= 62^65 % 133
Now that is really the only calculations that ill be doing. I have tried using Matt McCutchen's BigInteger Library, but I am g...
I often have to convert a retreived value (usually as a string) - and then convert it to an int. But in C# (.Net) you have to choose either int16, int32 or int64 - how do you know which one to choose when you don't know how big your retrieved number will be?
...
How can I write a function that takes an array of integers and returns true if their exists a pair of numbers whose product is odd?
What are the properties of odd integers? And of course, how do you write this function in Java? Also, maybe a short explanation of how you went about formulating an algorithm for the actual implementation.
...
Various questions (like this, and this) ask about how to handle integer values exceeding the native types of a particular language.
Please reply here, with one response per language, recommendations for libraries designed for handling very large numbers in various languages.
Where languages have built-in support for large numbers that'...
Would there be difference in speed between
if (myInt == CONST_STATE1)
and
if (myEnum == myENUM.State1)
in c#?
...
Why doesn't Java include support for unsigned integers? It seems to me to be an odd omission, given that they allow one to write code that is less likely to produce overflows on unexpectedly large input. Furthermore, using unsigned integers can be a form of self-documentation, as they indicate that the value that the unsigned int was i...
What is an easy way in Python to format integers into strings representing thousands with K, and millions with M, and leaving just couple digits after comma?
I'd like to show 7436313 as 7.44M, and 2345 as 2,34K.
Is there some % string formatting operator available for that? Or that could be done only by actually dividing by 1000 in a l...
In application frameworks I keep seeing frameworks that allow you to pass in multiple Int values (generally used in place of an enum) into a function.
For example:
public class Example
{
public class Values
{
public static final int ONE = 0x7f020000;
public static final int TWO = 0x7f020001;
public sta...
/**
* Returns a number between kLowerBound and kUpperBound
* e.g.: Wrap(-1, 0, 4); // Returns 4
* e.g.: Wrap(5, 0, 4); // Returns 0
*/
int Wrap(int const kX, int const kLowerBound, int const kUpperBound)
{
// Suggest an implementation?
}
...
A question I got on my last interview:
Design a function f, such that:
f(f(n)) == -n
Where n is a 32 bit signed integer; you can't use complex numbers arithmetic.
If you can't design such a function for the whole range of numbers, design it for the largest range possible.
Any ideas?
...
I got the question in the interview.
I had a difficulty in answering it.
I was not sure where I should start.
Finally, I discussed how the question is related to compilers and to their construction.
I was not sure what "compilers' integers" mean exactly.
It seems to me now that the word compiler was to confuse candidates.
How would y...
Hi,
I'm trying to make a constructor for a graph class that accepts a string as a
parameter and uses it to build the graph.
The string is formatted as follows: |vertex list|Edges list|
e.g. |1,2,3,4,15|(1->2),(3->2),(4->15)|
The idea is that the constructor will take the values from the string and then
know to perform the following a...
While doing some random experimentation with a factorial program in C, Python and Scheme. I came across this fact:
In C, using 'unsigned long long' data type, the largest factorial I can print is of 65. which is '9223372036854775808' that is 19 digits as specified here.
In Python, I can find the factorial of a number as large as 999 w...
I have a for loop generating integers.
For instance:
for (int i=300; i>200; i--)
{(somefunction)*i=n;
cout<<n;
}
This produces an output on the screen like this:
f=00000000000100023;
I want to store the 100023 part of this number (i.e just ignore all the zeros before the non zero numbers start but then keeping the zer...
I realize that this question may have been asked several times in the past, but I am going to continue regardless.
I have a program that is going to get a string of numbers from keyboard input. The numbers will always be in the form "66 33 9" Essentially, every number is separated with a space, and the user input will always contain a d...
Hi..
I want an integer to be multiples of 10,100,1000 and so on...
For eg double val = 35 then I want int 40
val = 357 then I want int val = 400
val = 245,567 then I want int val = 300,000
val = 245,567.986 then also I want int = 300,000
Is there anything in C# that can help in generating these integer
Basic logic that I can t...
What is the best possible way to send an int through a socket in Java? Right now I'm looking at
sockout.write((byte)( length >> 24 ));
sockout.write((byte)( (length << 8) >> 24 ));
sockout.write((byte)( (length << 16) >> 24 ));
sockout.write((byte)( (length << 24) >> 24 ));
and then trying to rebuild the int from bytes on the other s...
Hello,
I was having issues with an INT field where there may be no value, a zero value, or an integer above zero and since
SELECT foo FROM bar where foo = ''
evaluates identically to
SELECT foo FROM bar where foo = 0
I redefined foo like to foo INT(11) NULL so that rows where no value for foo is supplied do not get selected by e...
I have a lot of files with data to convert to percentages using basic math functions:
<param id="1" name="otb" value="0.160"/>
<param id="2" name="blm" value="-0.210"/>
<param id="3" name="mep" value="-0.010"/>
<param id="4" name="plc" value="-0.100"/>
Each id get's it's own equation:
(n-(-.3))/2.3*100
(n-(-.8))/3.3*100
(n-(-.5))/1....
I've been working a little bit on a Facebook application, but when I registered a new user to test the friend interaction the new user got a uid (100000XXXXXXXXX) that seems to big for php to handle.
Saving the number in the database results in the same value (2147483647). I'm guessing this is also PHPs fault, as I would believe the ui...