473,842 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prime number algorithm in C

HI,

is this is this solution to test if a number is a prime number or not:

/*
* Is n a prime number?
* Return TRUE (1): n is a prime number
* Return FALSE (0): n is a *not* a prime number
*/
int is_prime_number (int n)
{
long c;

if (n < 2) return FALSE;

for (c = 2; c < n; c++)
{
if ((n % c) == 0) return FALSE;
}
return TRUE;
}

Tia,

Chris
Nov 13 '05
32 76466
In <1f************ **************@ posting.google. com> lj****@tiscalin et.it (Lorenzo J. Lucchini) writes:
Da*****@cern.c h (Dan Pop) wrote in message news:<bp******* ****@sunnews.ce rn.ch>...
In <1f************ **************@ posting.google. com> lj****@tiscalin et.it (Lorenzo J. Lucchini) writes:
>Da*****@cern.c h (Dan Pop) wrote in message news:<bp******* ***@sunnews.cer n.ch>...
>> In <20************ *************** @mb-m20.aol.com> cm************@ aol.com (Cmorriskuerten ) writes:
>>
>>> [prime number algorithm]
>>
>> [snip]
>>
>> On the algorithm side: after testing divisibility by 2, there is no
>> point in checking divisibility by any other even number.
>
>Don't you think simply incrementing the counter by 2 instead of by 1
>is in a way a micro-optimization?


Nope, I don't: it accelerates the *algorithm*, not the implementation,
by a factor of 2. If this is a micro-optimization in your book, I would
be really interested to know what counts as a real optimisation to you.


I stand corrected. However, I must say that personally I would still
make a choice between testing for every number and only testing for
those numbers that are not multiples of a number I've already tested
for.
Testing for every number says "I want to make the algorithm as
straight-forward as possible".
Testing for non-multiples of tested numbers says "I want to make the
algorithm good"
Testing for every number except for multiples of two says "At the
beginning I thought I would need to test for every number; then I
realized I did not need to test for multiples of two; who knows, maybe
one day I'll even realize I don't need to test for multiples of *any*
number I've already tested for".


Welcome to the real world, where compromises are a fact of life.
You won't get very far without understanding this and acting accordingly.

The best choice is the one that is reasonably fast and reasonably easy to
implement. Your ideal algorithm may prove harder to implement and slower.

Your algorithm could be used as an alternative to Eratosthenes' sieve, if
the purpose was to find out *all* the prime numbers smaller than N, but
it would be overkill to test a single number for primeness.

Eratosthenes' sieve is going to be faster on dumb processors, where % is
typically a very slow operation, because it can be implemented using
additions only. It's also a very cache unfriendly algorithm, but dumb
processors seldom use cache ;-)

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #11
On 2003-11-20, Dan Pop <Da*****@cern.c h> wrote:
In <1f************ **************@ posting.google. com> lj****@tiscalin et.it (Lorenzo J. Lucchini) writes:
Testing for every number says "I want to make the algorithm as
straight-forward as possible".
Testing for non-multiples of tested numbers says "I want to make the
algorithm good"
Testing for every number except for multiples of two says "At the
beginning I thought I would need to test for every number; then I
realized I did not need to test for multiples of two; who knows,
maybe one day I'll even realize I don't need to test for multiples of
*any* number I've already tested for".


Your algorithm could be used as an alternative to Eratosthenes' sieve, if
the purpose was to find out *all* the prime numbers smaller than N, but
it would be overkill to test a single number for primeness.


The definition of the function may be to test a single number for
primeness, but it may be called many times for many numbers. It may
still be worth it to make the computation.

A shot at an implementation is in my signature. Not extensively tested.

-- James
--
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define ISQRT_G_1(N) (N>>((sizeof(N) *CHAR_BIT)/2))
#define ISQRT_G_2(N) ((ISQRT_G_1(N)+ N/ISQRT_G_1(N))/2)
#define ISQRT_G_3(N) ((ISQRT_G_2(N)+ N/ISQRT_G_2(N))/2)
#define ISQRT_G_4(N) ((ISQRT_G_3(N)+ N/ISQRT_G_3(N))/2)
#define ISQRT_G_5(N) ((ISQRT_G_4(N)+ N/ISQRT_G_4(N))/2)
#define ISQRT_G_6(N) ((ISQRT_G_5(N)+ N/ISQRT_G_5(N))/2)
#define ISQRT(N) ISQRT_G_6(N)

static unsigned long
isqrt(unsigned long N)
{
unsigned long r = N/2;

r = (r + N/r)/2;
r = (r + N/r)/2;
r = (r + N/r)/2;
r = (r + N/r)/2;
r = (r + N/r)/2;

return r;
}

static int prime_table_ini tialized;
static unsigned char prime_table[(ISQRT(ULONG_MA X)+(CHAR_BIT/2))/CHAR_BIT];
static unsigned prime_table_max = sizeof(prime_ta ble)*CHAR_BIT;
#define MAKE_PRIME(N) (void)(prime_ta ble[N/CHAR_BIT] |= (1U<<(N%CHAR_BI T)))
#define MAKE_UNPRIME(N) (void)(prime_ta ble[N/CHAR_BIT] &= ~(1U<<(N%CHAR_B IT)))
#define IS_PRIME(N) ((prime_table[N/CHAR_BIT] & (1U<<(N%CHAR_BI T))) != 0)

static void
isprime_sieve(v oid)
{
unsigned i;
unsigned j;

for (i = 0; i < prime_table_max ; i++) {
MAKE_PRIME(i);
}
MAKE_UNPRIME(0) ;
MAKE_UNPRIME(1) ;
for (i = 2; i < prime_table_max ; i++) {
if (IS_PRIME(i)) {
for (j = i+i; j < prime_table_max ; j += i) {
MAKE_UNPRIME(j) ;
}
}
}
prime_table_ini tialized = 1;
}

static int
isprime(unsigne d long n, unsigned long *f)
{
unsigned i;
unsigned long factor;
if (f == 0) f = &factor;
*f = 1;
if (prime_table_in itialized == 0) isprime_sieve() ;
if (n < 4) return IS_PRIME(n);
for (i = 2; i < prime_table_max ; i++) {
if (! IS_PRIME(i)) continue;
if (n % i == 0) return (*f = i), 0;
if (n/i <= i) return 1;
}
return 1;
}

int
main(int argc, char *argv[])
{
unsigned long n;
unsigned long m;
unsigned long f;
int i;

m = 0;
for (i = 1; i < argc; i++) {
n = strtoul(argv[i], 0, 0);
if (n > m) m = n;
}
prime_table_max = (isqrt(m)<prime _table_max) ? isqrt(m)+1 : prime_table_max ;
for (i = 1; i < argc; i++) {
n = strtoul(argv[i], 0, 0);
if (isprime(n,&f)) printf("%lu is prime\n", n);
else printf("%lu is not prime (f=%lu)\n", n, f);
}

return 0;
}
Nov 13 '05 #12
In <Lu************ ********@comcas t.com> James Hu <jx*@despammed. com> writes:
On 2003-11-20, Dan Pop <Da*****@cern.c h> wrote:
In <1f************ **************@ posting.google. com> lj****@tiscalin et.it (Lorenzo J. Lucchini) writes:
Testing for every number says "I want to make the algorithm as
straight-forward as possible".
Testing for non-multiples of tested numbers says "I want to make the
algorithm good"
Testing for every number except for multiples of two says "At the
beginning I thought I would need to test for every number; then I
realized I did not need to test for multiples of two; who knows,
maybe one day I'll even realize I don't need to test for multiples of
*any* number I've already tested for".


Your algorithm could be used as an alternative to Eratosthenes' sieve, if
the purpose was to find out *all* the prime numbers smaller than N, but
it would be overkill to test a single number for primeness.


The definition of the function may be to test a single number for
primeness, but it may be called many times for many numbers. It may
still be worth it to make the computation.


Then, it's much cleaner to use two functions: one that computes all
primes less than N, and another that uses the results of the first to
test whether a number less than N is prime or not. At its first
invocation, the latter calls the former, then it performs a bsearch on
the array containing the results. The other calls simply perform the
bsearch.

Things get more complicated if N is not known when the test function is
called for the first time. And the approach is suboptimal if the
function is called once for testing a number above 1 million and all the
other times for numbers less than 100.

So, it's hard to say what's best without knowing the full story.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #13
James Hu wrote:
[...]
#define ISQRT_G_1(N) (N>>((sizeof(N) *CHAR_BIT)/2))
#define ISQRT_G_2(N) ((ISQRT_G_1(N)+ N/ISQRT_G_1(N))/2)
#define ISQRT_G_3(N) ((ISQRT_G_2(N)+ N/ISQRT_G_2(N))/2)
#define ISQRT_G_4(N) ((ISQRT_G_3(N)+ N/ISQRT_G_3(N))/2)
#define ISQRT_G_5(N) ((ISQRT_G_4(N)+ N/ISQRT_G_4(N))/2)
#define ISQRT_G_6(N) ((ISQRT_G_5(N)+ N/ISQRT_G_5(N))/2)
#define ISQRT(N) ISQRT_G_6(N)


This isn't going to work very well for N less than
the square root of its type's maximum value: the initial
guess will be zero, and after that ...

There was a thread about three years ago regarding
implementations of integer square root functions without
resorting to a floating-point conversion. The fastest
used a 256-place table and an `if' ladder to produce an
initial guess close enough that only two Newton-Raphson
iterations were needed to refine it, and many smaller
values needed only one iteration. I was able to speed it
up just a hair more, and will provide it to anyone who's
interested. As coded it works only for 32-bit `unsigned
int', but the technique could be extended to wider types
with a fairly small expenditure of skull sweat.

--
Er*********@sun .com
Nov 13 '05 #14
Da*****@cern.ch (Dan Pop) wrote in message news:<bp******* ***@sunnews.cer n.ch>...
Then, it's much cleaner to use two functions: one that computes all
primes less than N, and another that uses the results of the first to
test whether a number less than N is prime or not. At its first
invocation, the latter calls the former, then it performs a bsearch on
the array containing the results. The other calls simply perform the
bsearch.

While building a table of primes it should be sufficient to test
whether the current candidate is divisible by one of the primes found
so far.

Here's my attempt at the problem ( I don't think it would be much
useful for testing an individual number for primeness)
#include <stdio.h>

#define MAXPRIMES 100

struct
{
int nprimes;
int primes[MAXPRIMES];
} prime_list={1,{ 2}};

int
main(void)
{
int i;
int num=10;/*buid a table of first "num" primes*/
for(i=3;prime_l ist.nprimes<num ;i+=2)
{
int j;
int isprime=1;
for(j=0;j<prime _list.nprimes;j ++)/* test if i is divisible by primes
found so far*/
{
if ( i%prime_list.pr imes[j] == 0)
{
isprime=0;
break;
}
}
if(isprime)/*new prime found push it on the list*/
{
prime_list.prim es[prime_list.npri mes++]=i;
}
}
/*print out the table of first num primes*/
for(i=0;i<prime _list.nprimes;i ++)
{
printf("%d\n",p rime_list.prime s[i]);
}
return 0;
}
Nov 13 '05 #15
On 2003-11-20, Eric Sosman <Er*********@su n.com> wrote:
James Hu wrote:
[...]
#define ISQRT_G_1(N) (N>>((sizeof(N) *CHAR_BIT)/2))
#define ISQRT_G_2(N) ((ISQRT_G_1(N)+ N/ISQRT_G_1(N))/2)
#define ISQRT_G_3(N) ((ISQRT_G_2(N)+ N/ISQRT_G_2(N))/2)
#define ISQRT_G_4(N) ((ISQRT_G_3(N)+ N/ISQRT_G_3(N))/2)
#define ISQRT_G_5(N) ((ISQRT_G_4(N)+ N/ISQRT_G_4(N))/2)
#define ISQRT_G_6(N) ((ISQRT_G_5(N)+ N/ISQRT_G_5(N))/2)
#define ISQRT(N) ISQRT_G_6(N)
This isn't going to work very well for N less than
the square root of its type's maximum value: the initial
guess will be zero, and after that ...


I wrote that macro specifically to find the square root of ULONG_MAX.
There was a thread about three years ago regarding
implementations of integer square root functions without
resorting to a floating-point conversion. ...


My macro is certainly faster for computing the square root of ULONG_MAX
than any function since it is computed at compile time, rather than
runtime. :-)

-- James
Nov 13 '05 #16
Eric Sosman <Er*********@su n.com> wrote in message news:<3F******* ********@sun.co m>...
James Hu wrote:
[...]
#define ISQRT_G_1(N) (N>>((sizeof(N) *CHAR_BIT)/2))
#define ISQRT_G_2(N) ((ISQRT_G_1(N)+ N/ISQRT_G_1(N))/2)
#define ISQRT_G_3(N) ((ISQRT_G_2(N)+ N/ISQRT_G_2(N))/2)
#define ISQRT_G_4(N) ((ISQRT_G_3(N)+ N/ISQRT_G_3(N))/2)
#define ISQRT_G_5(N) ((ISQRT_G_4(N)+ N/ISQRT_G_4(N))/2)
#define ISQRT_G_6(N) ((ISQRT_G_5(N)+ N/ISQRT_G_5(N))/2)
#define ISQRT(N) ISQRT_G_6(N)


This isn't going to work very well for N less than
the square root of its type's maximum value: the initial
guess will be zero, and after that ...

There was a thread about three years ago regarding
implementations of integer square root functions without
resorting to a floating-point conversion. The fastest
used a 256-place table and an `if' ladder to produce an
initial guess close enough that only two Newton-Raphson
iterations were needed to refine it, and many smaller
values needed only one iteration. I was able to speed it
up just a hair more, and will provide it to anyone who's
interested. As coded it works only for 32-bit `unsigned
int', but the technique could be extended to wider types
with a fairly small expenditure of skull sweat.


Hi,
I would be very much interested in the article. Could you
provide a link to that thread? And if you can, then the
speeded-up code too.
Regards and thanks,
Anupam
Nov 13 '05 #17
On 2003-11-21, Anupam <an************ **@persistent.c o.in> wrote:
Hi,
I would be very much interested in the article. Could you
provide a link to that thread? And if you can, then the
speeded-up code too.
Regards and thanks,
Anupam


I don't have a pointer to the thread, but this web page was an
interesting read:

http://www.azillionmonkeys.com/qed/sqroot.html

-- James
Nov 13 '05 #18
James Hu wrote:

On 2003-11-20, Eric Sosman <Er*********@su n.com> wrote:
James Hu wrote:
[...]
#define ISQRT_G_1(N) (N>>((sizeof(N) *CHAR_BIT)/2))
#define ISQRT_G_2(N) ((ISQRT_G_1(N)+ N/ISQRT_G_1(N))/2)
#define ISQRT_G_3(N) ((ISQRT_G_2(N)+ N/ISQRT_G_2(N))/2)
#define ISQRT_G_4(N) ((ISQRT_G_3(N)+ N/ISQRT_G_3(N))/2)
#define ISQRT_G_5(N) ((ISQRT_G_4(N)+ N/ISQRT_G_4(N))/2)
#define ISQRT_G_6(N) ((ISQRT_G_5(N)+ N/ISQRT_G_5(N))/2)
#define ISQRT(N) ISQRT_G_6(N)


This isn't going to work very well for N less than
the square root of its type's maximum value: the initial
guess will be zero, and after that ...


I wrote that macro specifically to find the square root of ULONG_MAX.


Aha. I hadn't realized the limited intent; sorry.

--
Er*********@sun .com
Nov 13 '05 #19
Anupam wrote:

Eric Sosman <Er*********@su n.com> wrote

There was a thread about three years ago regarding
implementations of integer square root functions without
resorting to a floating-point conversion. [...]
I would be very much interested in the article. Could you
provide a link to that thread?


Anupam: There's a wonderful service on the Internet,
known as Google. Among other things, Google maintains
searchable archives of Usenet newsgroups, including our
own comp.lang.c. Now, what do you suppose you find if
you go to http://groups.google.com and search for "integer
square root" in the comp.lang.c archives?
And if you can, then the
speeded-up code too.


It's just a few simple modifications to the code in
the first article of the cited thread. I also threw in
a whole lot of comments to describe what was going on;
it was essentially a "demonstrat ion piece." Here it is,
except that I've blotted some E-mail addresses out of
the source citations so as not to increase anyone's
exposure to spam:

/* HISTORY --
* 04-Jul-2002: Renamed the header file.
* 29-Jun-2000: Added a lot of comments.
* 19-May-2000: Original (see DESCRIPTION).
*/

/* DESCRIPTION --
* This function is a slight improvement on code posted to comp.lang.c by
* Lawrence Kirby (xx**@xxxxxxx.x xx), which seems to have been based on code
* by Dann Corbit (xx*****@xxxxxx xxxxx.xxx), which he in turn traces back to
* an 80386 assembly routine by one Arne Steinarson. Arne got the method from
* a fragment of temple wall retrieved from sunken Atlantis by Coq Jasteau;
* the stony text refers to the method as a gift from the "Ancient Astronauts"
* and hints of dire consequences to impious Atlanteans who affronted the
* Heavens by converting the method to binary from its original base seven.
*
* My principal improvement was to use a table of rounded rather than
* truncated first approximations; this reduced the number of cases requiring
* two Newton-Raphson iterations instead of just one. I also eliminated some
* needless additions of unity here and there, and got rid of a pessimization
* which tested for x >= 65535*65535. Finally, I rearranged the range tests
* along the lines suggested by Hermann Kremer (xx***********@ xxxxxx.xx),
* although whether this is a good idea or not depends on what sort of input
* distribution is anticipated.
*/

#include <limits.h>
#include "imath.h"

#if UINT_MAX != 0xFFFFFFFF
#error "This code needs a 32-bit unsigned integer"
#endif
unsigned int
isqrt(unsigned int x)
{
/* This table holds the rounded square roots of the integers 0..255, each
* expressed as a fixed-point binary number with four bits to the left and
* four bits to the right of the binary point. For example, sqrt(2) is
* 1.414... decimal or 1.01101... binary, which is rounded to 1.0111 and
* represented in the table as 0x17 == 23.
*/
static unsigned char est[0x100] = {
0, 16, 23, 28, 32, 36, 39, 42, 45, 48, 51, 53, 55, 58, 60, 62, 64, 66,
68, 70, 72, 73, 75, 77, 78, 80, 82, 83, 85, 86, 88, 89, 91, 92, 93, 95,
96, 97, 99, 100, 101, 102, 104, 105, 106, 107, 109, 110, 111, 112, 113,
114, 115, 116, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 139, 140, 141,
142, 143, 144, 145, 146, 147, 148, 148, 149, 150, 151, 152, 153, 153,
154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162, 163, 164, 165,
166, 166, 167, 168, 169, 169, 170, 171, 172, 172, 173, 174, 175, 175,
176, 177, 177, 178, 179, 180, 180, 181, 182, 182, 183, 184, 185, 185,
186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 195,
195, 196, 197, 197, 198, 199, 199, 200, 200, 201, 202, 202, 203, 204,
204, 205, 206, 206, 207, 207, 208, 209, 209, 210, 210, 211, 212, 212,
213, 213, 214, 215, 215, 216, 216, 217, 218, 218, 219, 219, 220, 221,
221, 222, 222, 223, 223, 224, 225, 225, 226, 226, 227, 227, 228, 229,
229, 230, 230, 231, 231, 232, 232, 233, 234, 234, 235, 235, 236, 236,
237, 237, 238, 238, 239, 239, 240, 241, 241, 242, 242, 243, 243, 244,
244, 245, 245, 246, 246, 247, 247, 248, 248, 249, 249, 250, 250, 251,
251, 252, 252, 253, 253, 254, 254, 255, 255 };
unsigned int r;

if (x >= 1U << 14) {
/* Some values in this range require at least one Newton-Raphson step
* to refine the initial estimate.
*/

if (x >= 1U << 30) {
r = est[x >> 24] << 8;
/* Some values in this range require two Newton-Raphson iterations
* instead of just one, so perform the first one here.
*/
r = (r + x / r) / 2;
}
else if (x >= 1U << 28)
r = est[x >> 22] << 7;
else if (x >= 1U << 26)
r = est[x >> 20] << 6;
else if (x >= 1U << 24)
r = est[x >> 18] << 5;
else if (x >= 1U << 22)
r = est[x >> 16] << 4;
else if (x >= 1U << 20)
r = est[x >> 14] << 3;
else if (x >= 1U << 18)
r = est[x >> 12] << 2;
else if (x >= 1U << 16)
r = est[x >> 10] << 1;
else
r = est[x >> 8] << 0;

/* Refine the estimate with one (or one more) Newton-Raphson step.
*/
r = (r + x / r) / 2;
}
else {
/* In this range, the initial estimate (after scaling and rounding)
* is very close and needs at most a small final tweak.
*/
if (x >= 1U << 12)
r = (est[x >> 6] + 1) >> 1;
else if (x >= 1U << 10)
r = (est[x >> 4] + 2) >> 2;
else if (x >= 1U << 8)
r = (est[x >> 2] + 4) >> 3;
else {
/* In this range, the initial estimate is exact and requires no
* tweaking at all.
*/
return est[x >> 0] >> 4;
}
}

/* Final tweak: The estimate (original or once- or twice-refined) is either
* correct as it stands or is one too large. (Don't worry about overflow
* in the multiplication; `r' is strictly less than 65536 here.)
*/
if (r * r > x)
--r;

return r;
}
--
Er*********@sun .com
Nov 13 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
8417
by: Dag | last post by:
Is there a python module that includes functions for working with prime numbers? I mainly need A function that returns the Nth prime number and that returns how many prime numbers are less than N, but a prime number tester would also be nice. I'm dealing with numbers in the 10^6-10^8 range so it would have to fairly efficient Dag
9
2718
by: Greg Brunet | last post by:
In doing some testing of different but simple algorithms for getting a list of prime numbers, I ended up getting some results that seem a bit contradictory. Given the following test program (testPrimes.py) with two algorithms that both check for primes by testing only odd numbers using factors up to the square root of the value, where Primes1 is based on all of the existing primes so far, and Primes2 is based on all odd numbers, I would...
5
2729
by: Rahul | last post by:
HI. Python , with its support of arbit precision integers, can be great for number theory. So i tried writing a program for testing whether a number is prime or not. But then found my function painfully slow.Here is the function : from math import sqrt def isPrime(x): if x%2==0 or x%3==0: return 0
11
5949
by: lostinpython | last post by:
I'm having trouble writing a program that figures out a prime number. Does anyone have an idea on how to write it? All I know is that n > 2 is prim if no number between 2 and sqrt of n (inclusivly) evenly divides n.
11
7167
by: don | last post by:
Ok, this is a homework assignment, but can you help me out anyway...... I need a routine for figuring out if a number inputted by the user is a prime number or not...... all I'm asking for is Not the exact code ( well maybe a little) but the logic or algorithm to tell whether or not a number is prime....
3
2759
by: ckroom | last post by:
Anyone knows a good algorithm to get the next prime of a number n? prime = nextprime( n ); It's for some stuff about double rehashing, thanks. -- ckroom http://nazaries.net/~ckroom
20
6831
by: Tuvas | last post by:
I have made and recently posted a libary I made to do Modular Arithmetic and Prime numbers on my website at http://www.geocities.com/brp13/Python/index.html . I am currently in a crypotology class, and am working on building a RSA public key cryptology system for a class project. I am building the librarys just to get the experience to do so. However, I would ask if any of you know of any gaping security holes that can easily be seen from...
60
1950
by: rhle.freak | last post by:
Here is my code to generate prime numbers.It works absolutely fine when the range is *not very large*. However on initializing i with a large integer it produces erroneous results (some numbers ending in 5 ..which obviously cannot be prime numbers) can anyone please help me out with the reason?? /*Generate Prime Numbers*/ #include<stdio.h>
2
2613
by: QHorizon | last post by:
Hello, I'm new to Python (I've learned everything up to iterators so far) and fairly new to Programming. This would be my first real program: #Coordinate Geometry (The whole program is not shown) import math import sys print "Welcome to the Coordinate Geometry Calculator!"
0
9867
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10939
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10669
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10308
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7853
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5695
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3140
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.