Re: Suggested method for returning a string from a C program?

Liste des GroupesRevenir à cl c  
Sujet : Re: Suggested method for returning a string from a C program?
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.c
Date : 22. Mar 2025, 18:12:13
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250322191213.00005ab2@yahoo.com>
References : 1 2 3 4 5
User-Agent : Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)
On Sat, 22 Mar 2025 13:25:43 +0000
Richard Heathfield <rjh@cpax.org.uk> wrote:

On 22/03/2025 08:07, Peter 'Shaggy' Haywood wrote:
 
<snip>
 
   Here's my solution, for what it's worth:
 
#include <stdio.h>
 
unsigned long weird(unsigned long n)
{
   printf("%lu", n);
 
   if(n & 1)
   {
     /* Odd - multiply by 3 & add 1. */
     n = n * 3 + 1; 
 
Or you can save yourself a multiplication
 
n = (n << 2) - (n - 1);
 
potentially shaving entire picoseconds off the runtime.
 
   }
   else
   {
     /* Even - divide by 2. */
     n /= 2; 
 
do
{
   n >>= 1;
} while(~(n & 1));
 
...and there goes another attosecond.
 



Date Sujet#  Auteur
20 Apr 26 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal