GCD approximation for type double numbers

AI Thread Summary
The discussion centers on a physics experiment where the user seeks an algorithm to identify a quantization pattern in their measurements. Specifically, they are looking for a method to find a double number that can divide a significant portion of their data while allowing for an arbitrary remainder. The user shares a code snippet for a double modulus function, which calculates the remainder of a division operation, ensuring that both numbers are positive. The focus is on finding effective algorithms for handling double precision numbers in the context of data analysis.
teleport
Messages
240
Reaction score
0
Hi, I am doing a phys experiment, and I find myself trying to obtain some pattern of quantization of some measurements, i.e., I'm trying to find a number (double) that divides at least a significant portion of my data, with an arbitrary remainder. Does anyone know of any algorithm that does this for type double numbers? I really need your help on this one. Thanks a lot.
 
Technology news on Phys.org
Code:
double mod(double n, double m) {
	if (n < 0)
		n = -n;
	if (m < 0)
		m = -m;
	int tmp = (int)(n / m);

	return n - tmp * m;
}
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top