20071117, 02:07  #1  
Dec 2005
2^{2}·23 Posts 
Implementing Chinese Remainder Theorem in C
I originally posted this on a programmer forum Microsoft has, but no one has replied, so I am reposting it here.
Quote:


20071117, 02:23  #2 
Aug 2002
140_{16} Posts 
The register keyword is extremely outdated and is ignored by all compilers. Local function prototypes are considered very bad style as well. There's no need to use calloc, when malloc would have sufficed. There's no need to pass "num" by pointer, you could just pass it by value.

20071117, 02:34  #3 
Dec 2005
1011100_{2} Posts 
Are you sure about the register keyword? I am using C89 and not C++ or C99. Also, I have been thinking about passing num as part of a structure, by using a wrapper structure around the remainder structure. I had a bad experience using malloc and I have been using calloc ever since. I will try using malloc again.
By the way, do you know how to break this up into separate files so I do not have to write the copy and paste the same functions into every program I wrote? Edit: Malloc works. Thanks for the tip. Last fiddled with by ShiningArcanine on 20071117 at 02:37 
20071117, 05:55  #4  
Aug 2002
2^{6}×5 Posts 
Quote:


Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Sorting on chinese remainder theorem  alpertron  Math  23  20171215 16:46 
Complexity of Chinese Remainder Theorem  carpetpool  Miscellaneous Math  4  20170209 19:26 
Basic Number Theory 6: functions and the Chinese Remainder Theorem  Nick  Number Theory Discussion Group  4  20161031 22:26 
Chinese Remainder Problem  ShiningArcanine  Math  2  20071117 10:01 
Implementing algorithms, did I do this right?  ShiningArcanine  Programming  18  20051229 21:47 