diff options
Diffstat (limited to '3/11_floating_point/01_fcvt.c')
| -rw-r--r-- | 3/11_floating_point/01_fcvt.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/3/11_floating_point/01_fcvt.c b/3/11_floating_point/01_fcvt.c new file mode 100644 index 0000000..a75ff48 --- /dev/null +++ b/3/11_floating_point/01_fcvt.c @@ -0,0 +1,17 @@ +#include <stdio.h> +double fcvt(int i, float *fp, double *dp, long *lp) { + float f = *fp; double d = *dp; long l = *lp; + *lp = (long) d; // double->long + *fp = (float) i; // int->float + *dp = (double) l; // long->double + return (double) f; // float->double +} + +int main(void) { + float f = 0.5f; double d = 1.0; long l = 1; + + float *fp = &f; double *dp = &d; long *lp = &l; + + fcvt(42, fp, dp, lp); + return 0; +} |
