conversion: macrofied conversion
This commit is contained in:
26
silly.c
26
silly.c
@@ -97,22 +97,20 @@ silly make_silly(short sign, int before, int after) {
|
||||
return s;
|
||||
}
|
||||
|
||||
#define FROM(n) {\
|
||||
silly s;\
|
||||
double _;\
|
||||
s.sign = signbit(x);\
|
||||
x = fabs(x);\
|
||||
s.before = trunc(x);\
|
||||
s.after = modf(x, &_);\
|
||||
return s;\
|
||||
}
|
||||
|
||||
silly silly_from_float(float x) {
|
||||
silly s;
|
||||
double _;
|
||||
s.sign = signbit(x);
|
||||
x = fabs(x);
|
||||
s.before = trunc(x);
|
||||
s.after = modf(x, &_);
|
||||
return s;
|
||||
FROM(x);
|
||||
}
|
||||
|
||||
silly silly_from_double(double x) {
|
||||
silly s;
|
||||
double _;
|
||||
s.sign = signbit(x);
|
||||
x = fabs(x);
|
||||
s.before = trunc(x);
|
||||
s.after = modf(x, &_);
|
||||
return s;
|
||||
FROM(x);
|
||||
}
|
||||
|
Reference in New Issue
Block a user