Can a 32-bit hash be made into a 64-bit hash by calling it twice with different seed?

If I have a hash function that generates a 32 bit result with a good distribution (say murmur3):

var h32 = hash32(str, seed);  // returns a 32bit hex string (8 chars): '0123abcd' 

it will still generate collisions with a probability of 50% when I have 77163 samples.

Can I create a 64 bit hash with equally good distribution by simply concatenating the result strings of two calls with different seed?

For example

h64 = hash32(str, seed1) + hash32(str, seed2);  // '0123abcd8d4f614a' 

or by modifying the input slightly on the second call

h64 = hash32(str) + hash32(str + 'x');  // '0123abcd8d4f614a' 

Or put it another way:

If hash32('foo') == hash32('bar'), can I assume that hash32('foo'+'x') == hash32('bar'+'x') is completely independent / unlikely?

UPDATE: thinking about it, this will probably not work if the hash algorithm works incrementally character-by-character, so this will not help either:

h64 = hash32(str) + hash32(str + str); 

So I rather ask for a way to ‘build a 64-bit hash if only a 32-bit hash function is available.’

Encoding of timestamps over cosmological time (64-bit linear vs 32-bit logarithmic)

I understand this is the place to ask questions pertaining to software design. If my question is considered to opinion-based, is there a forum or something better suited for the discussion?

Objective

My goal is to develop an application which can store & manipulate “historical data” covering the full range of time from the Big Bang (13.7 Ga) to the present day without loss of precision in the modern era. This encoding system should ideally represent dates as integers for the sake of fast queries. There is expected to be >100,000 records with dates spread throughout cosmological time but increasing in density towards the present day.

The will be a far larger number of records in the Holocene than in the several billion years preceding it. These records will also be dated to a higher precision; very recent events might have a time of day, requiring precision down to 1 second. Much older events might only be known to within a few thousand years, or more. I do not want to divide the timeline into sections! It is important than dates are handled in a consistent way across all of time, since any division would be arbitrary and un-physical.

Discussion/Solution

The existing UNIX epoch time is a good candidate to start from, already encoding timestamps to 1 second precision in a signed integer format. However, this scheme cannot handle very old dates given that the number of seconds since the Big Bang is approx. 4.3×10^17 which far exceeds the range of a 32-bit integer.

I see two potential solutions to this:

  1. Replace the 32-bit integer with a 64-bit integer, extending the range to roughly 1.8×10^19 (~50 times the required amount). The advantage of this method is that the encoding system remains linear and uniform. The disadvantage is in storage space and query time.
  2. Given the observation that precision is less important the farther back in time we go, we can consider the possibility of sticking with 32-bit integers, but using some kind of logarithmic scale instead. In this scheme, contiguous integers close to the modern age would represent a time difference of ~1 second, and this value would increase as we go back in time.

The signed range of a 32-bit integer is ~2.1 billion. Averaged over the entire history of the universe, this equates to roughly 6.3 years per integer, which is a promising result. If recent history skews this value towards ~1 second per integer, this can be balanced by skewing in the other direction at the opposite extreme. i.e. something like 100,000 years per integer in the vicinity of the Big Bang.

Thus, by taking advantage of the increasing uncertainty in dates as we move backwards in time, it is theoretically possible to encode all of cosmic history using a logarithmic 32-bit integer scale without losing precision in modern times… But is this a better approach? Do the performance benefits of 32-bit integers outweigh the cost of using a logarithmic scale?

Installing/Dual Booting a Linux-based on a MacBook Pro 8,1 with Windows 7 32-bit (with OS X removed) without completely wiping the hard drive [on hold]

I have in my possession is a MacBook 8,1 without its native Mac OS X and replaced with Windows (with Boot Camp). My problem is that I can’t really use most of the resources online as it uses the Mac OS X utilities to achieve certain things (like rEFInd and Boot Camp Assitant). The solutions I have come up with is just dual booting macOS again using the Internet Recovery, but this is giving me a big headache since the only hard drive in this MacBook is in “MBR” although I doubt it since I’ve read that Bootcamp using a MBR/GPT hybrid scheme thingy which is probable since I saw that the Mac OS X Base System partition is in MacOS format. I don’t want to format the hard drive since I don’t own a backup drive and there are some personal files in here, so I searched a safe way and doing it and found out that I can convert MBR to GPT using a program called AOMEI Partition Manager but it does not support 32-bit (which the version of Windows 7 I have). Sorry for the messy grammar not really what I excel at and I’m really frustrated at this point.

How does the memory of a 64bit and 32bit processor work

In this article, the author states that a 64bit processor can theoretically reference 2^64 bytes of memory. What does he mean by this statement, or rather the word, reference?

Also, I visualize the entire RAM to be divided into little memory cells, each having an n-bit binary number that represents a given instruction or value that is needed for running any program in the computer. Is this visualization right?

If it is, then for a 64bit processor, what would be the number of memory cells in the RAM?

Reverse int within the 32-bit signed integer range: \$[−2^{31}, 2^{31} − 1]\$ Optimized

LeetCode Problem

Reverse digits of a 32-bit signed integer. When the reversed integer overflows return 0.

Feedback

Optimized from beta code in the original question here. Based on this LeetCode problem.. I’m trying to come up with a good approach that just math operations to iterate a serious of digits using division, almost treating the int like a stack poping using modulus, and pushing using multiplication. I think there still may be some overflow edge cases I am not catching like 1534236469, but need some help coming up with how to detect and prevent such cases.

#include <cassert> #include <climits> #include <cmath> #include <iostream>  class Solution  {     public:         int reverse(int i) {              if(i > INT_MAX || i < INT_MIN) {                 return 0;             }                                         int sign = 1;             if(i < 0) {                  sign = -1;                 i = i*sign;             }              int reversed = 0;             int pop = 0;              while(i > 0) {                       pop = i % 10;                 reversed = reversed*10 + pop;                 i /= 10;             }                                              std::cout << reversed << '\n';              return reversed*sign;         } };  int main() {     Solution s;          assert(s.reverse(1) == 1);     assert(s.reverse(0) == 0);     assert(s.reverse(123) == 321);     assert(s.reverse(120) == 21);     assert(s.reverse(-123) == -321);     assert(s.reverse(1207) == 7021);         assert(s.reverse(1534236469) == 0);     assert(s.reverse(-2147483412) == -2143847412); } 

Reverse int within the 32-bit signed integer range: [−2^31, 2^31 − 1]

Problem

Reverse digits of a 32-bit signed integer. When the reversed integer overflows return 0.

Feedback

Looking for any ways I can optimize this with modern c++ features overall. I hope my use of const correctness, exception handling, and assertions is implemented well here, please let me know. Is there any way I can use byte operations to reverse the int and keep track of the sign possibly?

Based on the submission feedback from LeetCode, is it safe to say that the time complexity is O(n) and space complexity is O(n)? If I can reduce the complexity in anyway would love to know! Thanks for the feedback in advance.

enter image description here

#include <cassert> #include <climits> #include <stdexcept> #include <string>  class Solution  {     public:         int reverse(int i) {             bool is_signed = false;             if(i < 0) { is_signed = true; }              auto i_string = std::to_string(i);              std::string reversed = "";             while(!i_string.empty()) {                 reversed.push_back(i_string.back());                         i_string.pop_back();             }              try {                 i = std::stoi(reversed);             } catch (const std::out_of_range& e) {                 return 0;             }              if(is_signed) { i *= -1; }              return i;         } };  int main() {     Solution s;     assert(s.reverse(1) == 1);     assert(s.reverse(0) == 0);     assert(s.reverse(123) == 321);     assert(s.reverse(120) == 21);     assert(s.reverse(-123) == -321);     assert(s.reverse(1207) == 7021);         assert(s.reverse(INT_MAX) == 0);     assert(s.reverse(INT_MIN) == 0); } 

Converting a decimal to IEEE754 32-bit binary number


Convert 0.625 to IEEE754 32-bit binary number.

0.625 x 2 = 1.250 0.250 x 2 = 0.500 0.500 x 2 = 1.000 

So,

0.625 = 0.101   => 0.625 = 1.01 x 2^(-1) 

So,

S = 0 E = -1+127 = 126 => 01111110 M = 01 => 0100000 00000000 00000000  

I am confused with the mantissa part.

Would it be

M = 01 => 0100000 00000000 00000000 

Or,

M = 01 => 0000000 00000000 00000001 

?

Installation of Teamviewer on Ubuntu 17.04 does not work (32-Bit machine)

I installed Ubuntu 17.04 on my 32-Bit notebook (previously used a WinXP-machine).
The notebook is a 32-Bit machine with 3GB RAM. Installtion of Ubuntu 17.04 worked fine.
I then tried to install Teamviewer (downloaded file teamviewer_14.1.18533_i386.deb), but constantly failed. During – incomplete – installation of Teamviewer I received messages about missing files/packages like

libqt5x11extras5
qt56-teamviewer
qml-module-qtquick-controls
qml-module-qtquick-dialogs

I had to remove Teamviewer from my system.
I am a rather unexperienced Ubuntu-user and wonder if someone can help me out with a description of steps to walk through when installing Teamviewer, especially how to install a .deb-file including all dependancies which might be necessary.

Thanks for your support. Best regards Michael

What are some good books for learning 32bit MIPS single and multi cycle implementation?

I know of patterson and I don’t find it sufficiently detailed. It jumps from one thing to another without covering details. My architecture course in college consists of:

  1. control and datapath of single and multi cycle implementation

  2. pipelining and its implementation

  3. hazards and fixes withimplementation

all implementation are in verilog. I’m not concerned about the implementation part. I just want to learn everything in detail from basics.