I'm looking for a CPAN module that will take a short string:
my $hash_value = hash_this('short string not too long');
And hash it into an integer key:
say $hash_value;
12345671234 # an integer key
...
I have some code that does a lot of comparisons of 64-bit integers, however it must take into account the length of the number, as if it was formatted as a string. I can't change the calling code, only the function.
The easiest way (besides .ToString().Length) is:
(int)Math.Truncate(Math.Log10(x)) + 1;
However that performs rather po...
Hello,
the code below(in C++) is what I am trying the convert into C#
DWORD Func_X_4(DWORD arg1, DWORD arg2, DWORD arg3)
{
LARGE_INTEGER result = {1, 0};
LARGE_INTEGER temp1 = {0};
LARGE_INTEGER temp2 = {0};
LARGE_INTEGER temp3 = {0};
LARGE_INTEGER temp4 = {0};
for(int x = 0; x < 32; ++x)
{
if(arg2 & 1)
{
temp1.LowPart = arg3;
te...
I'm trying to read user input of integer. (like cin >> nInput; in C++)
I found io:fread bif from http://www.erlang.org/doc/man/io.html, so I write code like this.
{ok, X} = io:fread("input : ",
"~d"), io:format("~p~n", [X]).
but when I input 10, the erlang terminal keep giving me "\n" not 10. I assume fread automatically read 10 ...
How do you format a number as a string so that it takes a number of spaces in front of it? I want the shorter number 5 to have enough spaces in front of it so that the spaces plus the 5 have the same length as 52500. The procedure below works, but is there a built in way to do this?
a = str(52500)
b = str(5)
lengthDiff = len(a) - len(...
I want to get, given a character, its ascii value.
For example, for the character 'a', I want to get 97,
and viceversa.
Thanks,
Manuel
...
for (iy = 0; iy < h; iy++)
{
double angy = (camera.fov_y / h) * iy;
for (ix = 0; ix < w; ix++)
{
double angx = (camera.fov_x / w) * ix;
//output[ix,iy].r = (int)Math.Round(255 * (angy / camera.fov_y);
//output[ix,iy].b = (int)Math.Round(255 * (angy / camera.fov_y);
...
Let's say I have a byte-stream in which I know the location of a 64-bit value (a 64-bit nonce). The byte-order is Little-Endian. As PHP's integer data-type is limited to 32-bit (at least on 32-bit operating systems) how would I convert the byte-sequence into a PHP numeric representation (float would be sufficient I think)?
$serverChalle...
If I execute the following code in C:
#include <stdint.h>
uint16_t a = 4000;
uint16_t b = 8000;
int32_t c = a - b;
printf("%d", c);
It correctly prints '-4000' as the result. However, I'm a little confused: shouldn't there be an arithmetic overflow when subtracting a larger unsigned integer from the other? What casting rules are ...
I'm going through the "Head First C#" book and in one of the chapters I created a program and uses variables declared as ints and decimals. Visual Studio got cranky with me a couple of times about mixing and matching the two. For example:
dinnerParty.NumberOfPeople = (int) numericUpDown1.Value;
NumberOfPeople is declared as an int an...
Hello :)
I'm writing a compressor for a long stream of 128 bit numbers. I would like to store the numbers as differences -- storing only the difference between the numbers rather than the numbers themselves because I can pack the differences in fewer bytes because they are smaller.
However, for compression then I need to subtract these...
Hi
I'm trying to make a website in which a user inputs details on one screen, and they are posted onto the following script. This script is meant to store these details in a database along with a unique integer ID (which it does), and then generate two links containing the unique ID of the record just created. Since the database creates...
Does anyone know of a Ruby module that will take an integer and spell it out ( 1 => "one", 2 => "two", etc..)?
...
Can I compare a floating-point number to an integer?
Will the float compare to integers in code?
float f; // f has a saved predetermined floating-point value to it
if (f >=100){__asm__reset...etc}
Also, could I...
float f;
int x = 100;
x+=f;
Sorry, I don't have a lot of experience using floating point. But ultimately I ha...
I need to calculate modulus with large number like :
<?php
$largenum = 95635000009453274121700;
echo $largenum % 97;
?>
It's not working... beacause $largenum is too big for an int in PHP.
Any idea how to do this ?
...
In 32 bit integer math, basic math operations of add and multiply are computed implicitly mod 2^32, meaning your results will be the lowest order bits of the add or multiply.
If you want to compute the result with a different modulus, you certainly could use any number of BigInt classes in different languages. And for values a,b,c < 2^3...
Hello,
Imagine we have 5 string variables and we want to assign "Foo" to them during runtime.
Instead of this
string a1 = "Foo";
string a2 = "Foo";
string a3 = "Foo";
string a4 = "Foo";
string a5 = "Foo";
Can't we use something like this:
for(int i = 0;i < 5;i++)
{
a+i = "Foo";
}
Is it impossible to access them in a similiar ...
How do I write the magic function below?
>>> num = 123
>>> lst = magic(num)
>>>
>>> print lst, type(lst)
[1, 2, 3], <type 'list'>
...
Hello there, peoples of web!
Maybe one of you will spot what's amiss in the following function:
It is a javascript function used on a textbox client-side onblur event to validate that the entered text represents a correctly formatted and valid date.
I tried a few times, and it worked, but it seems ! should've tried all dates!
it will ...
Given a list of integers, how can I best find an integer that is not in the list?
The list can potentially be very large, and the integers might be large (i.e. BigIntegers, not just 32-bit ints).
If it makes any difference, the list is "probably" sorted, i.e. 99% of the time it will be sorted, but I cannot rely on always being sorted.
...