Commit | Line | Data |
---|---|---|
5437598b MD |
1 | /* this file is #include'd (several times) by numbers.c */ |
2 | ||
3 | FTYPE | |
4 | NUM2FLOAT (SCM num, unsigned long int pos, const char *s_caller) | |
5 | { | |
6 | if (SCM_INUMP (num)) | |
7 | return SCM_INUM (num); | |
8 | else if (SCM_BIGP (num)) | |
9 | { /* bignum */ | |
78c53d7e | 10 | FTYPE res = mpz_get_d (SCM_I_BIG_MPZ (num)); |
2c0334ec | 11 | if (! xisinf (res)) |
5437598b MD |
12 | return res; |
13 | else | |
14 | scm_out_of_range (s_caller, num); | |
15 | } | |
16 | else if (SCM_REALP (num)) | |
17 | return SCM_REAL_VALUE (num); | |
18 | else | |
19 | scm_wrong_type_arg (s_caller, pos, num); | |
20 | } | |
21 | ||
22 | SCM | |
23 | FLOAT2NUM (FTYPE n) | |
24 | { | |
3553e1d1 | 25 | SCM z = scm_double_cell (scm_tc16_real, 0, 0, 0); |
5437598b MD |
26 | SCM_REAL_VALUE (z) = n; |
27 | return z; | |
28 | } | |
29 | ||
30 | /* clean up */ | |
31 | #undef FLOAT2NUM | |
32 | #undef NUM2FLOAT | |
33 | #undef FTYPE | |
34 | ||
35 | /* | |
36 | Local Variables: | |
37 | c-file-style: "gnu" | |
38 | End: | |
39 | */ |