# Search:

Type: Posts; User: rcgldr

Page 1 of 20 1

1. ## Thread: How to factor a number of 100 characters into prime factors in 1-2 seconds?

by rcgldr
Replies
6
Views
1,534

### If the the factors are all large prime numbers...

If the the factors are all large prime numbers it's going to take quite a while, but for 2^512-1, one of the factors is a 62 digit prime, and that takes a fraction of a second.
2. ## Thread: How to factor a number of 100 characters into prime factors in 1-2 seconds?

by rcgldr
Replies
6
Views
1,534

### Here is a link to an online factoring program...

Here is a link to an online factoring program that also includes source code, that finds the the factors for that large number in a fraction of a second.

Integer factorization calculator

The...
3. ## Thread: what is goto?

by rcgldr
Replies
3
Views
1,007

### Sometimes goto is useful as shown in the threads...

Sometimes goto is useful as shown in the threads linked to below. The first is about a 4 way merge sort that doesn't use a min-heap. The second is a more generic question. Typically goto is useful...
4. ## Thread: IDE for C programming

by rcgldr
Replies
2
Views
1,896

### Visual Studio is not running some type of virtual...

Visual Studio is not running some type of virtual mode. Instead, it knows the acceptable syntax for C / C++ and also some common errors, so it will produce errors or warnings as you type in code.

by rcgldr
Replies
6
Views
2,557

### I forgot to reply to this before. It's possible...

I forgot to reply to this before. It's possible that the amount of sensitivity to alignment may be specific to the Intel 3770K or any of the third generation of processors known as "Ivy Bridge",...

by rcgldr
Replies
6
Views
2,557

### Example C++ code for Windows. Converting the code...

Example C++ code for Windows. Converting the code to C is simple, but more effort would be needed to convert to Posix semaphores and threads. This example takes about 0.4 seconds to sort 36 million...

by rcgldr
Replies
6
Views
2,557

### I modded a radix sort for 36 million psuedo...

I modded a radix sort for 36 million psuedo random 64 bit integers, using (8,8,8,8,8,8,8,8) bit fields (8 passes), to use 4 threads corresponding to the 4 cores on my processor (Intel 3770K). The...

by rcgldr
Replies
6
Views
2,557

### The code in the prior thread could use some minor...

The code in the prior thread could use some minor tweaks to make it a bit faster, but it's at a point of diminishing returns. As pointed out in the prior thread, if sorting 64 bit unsigned integers,...
9. ## Thread: How can I optimize this function that merges two ordered linked lists?

by rcgldr
Replies
6
Views
2,532

### This is similar to john.c's answer, but only...

This is similar to john.c's answer, but only checks for a == NULL or b == NULL as needed, instead of a while that checks both for every node moved.

ListNode * MergeLists(ListNode *a, ListNode...
10. ## Thread: Lotto 6/49 program

by rcgldr
Replies
53
Views
13,952

### One issue with the suggested solutions is that...

One issue with the suggested solutions is that the results will be slightly biased due to rand%(x), where x ranges from 49 to 44. For example, if using a 32 bit random number generator modulo 49,...
11. ## Thread: global vs static variable

by rcgldr
Replies
10
Views
3,201

### By older compilers, I meant ones that aren't c89...

By older compilers, I meant ones that aren't c89 compliant. This would include most 16 bit compilers for X86 (like Microsoft (although the last 16 bit tool set was released in 1994, I don't think...
12. ## Thread: global vs static variable

by rcgldr
Replies
10
Views
3,201

### Depending on the compiler (usually older ones),...

Depending on the compiler (usually older ones), global variables may not be initialized, unless explicitly initialized, while static variables are initialized to zero by default.
13. ## Thread: Linear feedback shift register (LFSR)

by rcgldr
Replies
2
Views
4,121

### There are two types of LFSR, Fibonacci and...

There are two types of LFSR, Fibonacci and Galois. The question doesn't specify which type. Wiki article:

Linear-feedback shift register - Wikipedia
14. ## Thread: Intel 3770K ~35% time difference in tight loop depending on location - other cpus?

by rcgldr
Replies
5
Views
2,051

### Those are possible explanations for variations in...

Those are possible explanations for variations in run time, but they don't explain a consistent difference in run time (1.465 seconds versus 2.000 seconds) due to location of code.
15. ## Thread: Intel 3770K ~35% time difference in tight loop depending on location - other cpus?

by rcgldr
Replies
5
Views
2,051

### Possibly, but Windows non-I/O thread switches...

Possibly, but Windows non-I/O thread switches only occur on tick boundaries, and at 64 hz, 2 seconds, that is 128 possible thread switches out of 1048576 calls to fib(), or 8192 calls per possible...
16. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

### I posted it in the tech board section: ...

I posted it in the tech board section:

https://cboard.cprogramming.com/tech-board/177912-intel-3770k-~35%-time-difference-tight-loop-depending-location-other-cpus.html#post1288661
17. ## Thread: Intel 3770K ~35% time difference in tight loop depending on location - other cpus?

by rcgldr
Replies
5
Views
2,051

### Intel 3770K ~35% time difference in tight loop depending on location - other cpus?

The code below is X86 64 bit assembly code to calculate the sum of Fib(0) to Fib(93). It includes a conditional to use either a tight loop or an unfolded loop with a computed jump to enter the...
18. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

### One issue I found with 3770K was an unusual...

One issue I found with 3770K was an unusual sensitivity to code location in tight loops. I was comparing 64 bit assembly code for Fibonacci number using a tight loop versus an unfolded loop,...
19. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

### My prior testing was wrong, on my 3770K at...

My prior testing was wrong, on my 3770K at 3.5ghz, 64 bit mode, original takes ~1.18, alternate ~1.26 seconds, about 6.6% slower, not much of a difference.
20. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

### Can't you use the code from your prior post? I...

Can't you use the code from your prior post? I made a different version of main, calls rand() multiple times since VS rand() only returns 15 bits (it also matches some other old code used for...
21. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

### This code is used to handle the case where a...

This code is used to handle the case where a single sorted run is all that is remaining to the end of the array, so it just does a copy of that single run. Calling Merge201 after that looks like it...
22. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

I never got a reply about the call to Merge201 after doing a MergeCopy10.

I'm also wondering if the original version is easier to follow than the alternate version. The original version...
23. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

### Thanks The code in main needs to check the...

Thanks

The code in main needs to check the array pointed to by the returned pointer in "result" (instead of dest or source). To end up with the sorted array in the original array (not the working...
24. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

### ... and in 1974, Donald Knuth wrote "Structured...

... and in 1974, Donald Knuth wrote "Structured Programming with go to Statements" (you can do a web search to find copies of the original paper). The point of creating this thread is that I rarely...
25. ## Thread: Sometimes "goto" is useful

by rcgldr
Replies
15
Views
6,710

### Sometimes "goto" is useful

Here is an example of a 4 way (no minheap) bottom up merge sort, which is about 15% faster than a 2 way merge sort and about as fast (sometimes a bit faster) than quick sort, on a processor with 16...
Results 1 to 25 of 500
Page 1 of 20 1