ROOT
6.30.04
Reference Guide
All
Namespaces
Files
Pages
TMathBase.cxx
Go to the documentation of this file.
1
// @(#)root/base:$Id$
2
// Authors: Rene Brun 08/02/2007
3
4
/*************************************************************************
5
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6
* All rights reserved. *
7
* *
8
* For the licensing terms see $ROOTSYS/LICENSE. *
9
* For the list of contributors see $ROOTSYS/README/CREDITS. *
10
*************************************************************************/
11
12
/** TMath Base functions
13
\ingroup Base
14
15
Define the functions Min, Max, Abs, Sign, Range for all types.
16
NB: These functions are unfortunately not available in a portable
17
way in std::.
18
19
More functions are defined in TMath.h. TMathBase.h is designed to be
20
a stable file and used in place of TMath.h in the ROOT miniCore.
21
*/
22
23
#include "
TMathBase.h
"
24
#include <math.h>
25
26
////////////////////////////////////////////////////////////////////////////////
27
/// Return next prime number after x, unless x is a prime in which case
28
/// x is returned.
29
30
Long_t TMath::NextPrime(Long_t x)
31
{
32
if
(x <= 2)
33
return
2;
34
if
(x == 3)
35
return
3;
36
37
if
(x % 2 == 0)
38
x++;
39
40
Long_t sqr = (Long_t) sqrt((Double_t)x) + 1;
41
42
for
(;;) {
43
Long_t n;
44
for
(n = 3; (n <= sqr) && ((x % n) != 0); n += 2)
45
;
46
if
(n > sqr)
47
return
x;
48
x += 2;
49
}
50
}
TMathBase.h
core
base
src
TMathBase.cxx
Generated on Tue May 5 2020 14:02:20 for ROOT by
1.8.5