Numworks Epsilon
1.4.1
Graphing Calculator Operating System
random.cpp
Go to the documentation of this file.
1
#include <
poincare/random.h
>
2
#include <
ion.h
>
3
4
extern
"C"
{
5
#include <
assert.h
>
6
}
7
#include <cmath>
8
9
namespace
Poincare
{
10
11
Expression::Type
Random::type
()
const
{
12
return
Type::Random
;
13
}
14
15
Expression
*
Random::clone
()
const
{
16
Random
* a =
new
Random
();
17
return
a;
18
}
19
20
Expression
* Random::setSign(Sign s,
Context
& context, AngleUnit angleUnit) {
21
assert
(s ==
Sign::Positive
);
22
return
this
;
23
}
24
25
template
<
typename
T>
T
Random::random
() {
26
if
(
sizeof
(
T
) ==
sizeof
(
float
)) {
27
uint32_t
r =
Ion::random
();
28
return
(
float
)r/(float)(0xFFFFFFFF);
29
}
else
{
30
assert
(
sizeof
(
T
) ==
sizeof
(
double
));
31
uint64_t
r;
32
uint32_t
* rAddress = (
uint32_t
*)&r;
33
*rAddress =
Ion::random
();
34
*(rAddress+1) =
Ion::random
();
35
return
(
double
)r/(double)(0xFFFFFFFFFFFFFFFF);
36
}
37
}
38
39
template
float
Random::random
();
40
template
double
Random::random
();
41
42
}
Poincare::Context
Definition:
context.h:9
assert
#define assert(e)
Definition:
assert.h:9
ion.h
Poincare::Expression::Type::Random
Poincare::Expression::Sign::Positive
T
#define T(x)
Definition:
events.cpp:26
Poincare
Definition:
absolute_value.h:8
Ion::random
uint32_t random()
Definition:
device.cpp:52
assert.h
Poincare::Random::random
static T random()
Definition:
random.cpp:25
uint32_t
unsigned int uint32_t
Definition:
stdint.h:6
Poincare::Random::clone
Expression * clone() const override
Definition:
random.cpp:15
uint64_t
unsigned long long uint64_t
Definition:
stdint.h:7
Poincare::Random::type
Type type() const override
Definition:
random.cpp:11
Poincare::Expression::Type
Type
Definition:
expression.h:84
Poincare::Expression
Definition:
expression.h:16
random.h
Poincare::Random
Definition:
random.h:10
epsilon
poincare
src
random.cpp
Generated by
1.8.14