-
Notifications
You must be signed in to change notification settings - Fork 0
/
cintpcvt.d
49 lines (31 loc) · 1.13 KB
/
cintpcvt.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
static assert({return 2f;}() == 2f);static assert({return 2fi;}() == 2fi);
static assert({return 2.0;}() == 2.0);static assert({return 2.0i;}() == 2.0i);
static assert({return 2.0L;}() == 2.0L);static assert({return 2.0Li;}() == 2.0Li);
static assert({return ' ';}() == ' ');
uint x(float a){return cast(uint)a;}
uint x(double a){return cast(uint)a;}
uint x(real a){return cast(uint)a;}
static assert(x(1.5f) == 1);
static assert(x(1.5) == 1);
static assert(x(1.5L) == 1);
static assert(x(1e228) == 0);
pragma(msg, ((double x)=>(double y)=>x+y)(2)(3));
static assert((double x){return cast(short)cast(ulong)x;}(1e10) == -7168);
static assert(((double x)=>cast(short)x)(1e10) == -7168);
int y(float a){return cast(int)a;}
int y(double a){return cast(int)a;}
int y(real a){return cast(int)a;}
//static assert((x){return cast(int)x;}(2.0L) == 2);
//static assert({return cast(float)
//pragma(msg, {return 2.0i+1;}());
const(int) constvar = 2;
static assert(constvar==2);
uint foo(int x, real y){
if(x) return cast(uint)y;
if(100-100.0) return 2;
else if(true) return 3;
else return 0;
}
void main(){
pragma(msg, foo(10,202.5L+119.6));
}