FreeBASIC  0.91.0
math_cvn.c
Go to the documentation of this file.
1 /* CV# numeric routines */
2 
3 #include "fb.h"
4 
5 #define hDoCVn(from, to_t, size) do { \
6  if( (size) == sizeof(from) && (size) == sizeof(to_t) ) \
7  { \
8  to_t to; \
9  memcpy( &to, &from, size ); \
10  return to; \
11  } \
12  else \
13  { \
14  return (to_t)0; \
15  } \
16  } while (0)
17 
18 
19 FBCALL double fb_CVDFROMLONGINT( long long ll )
20 {
21  hDoCVn( ll, double, 8 );
22 }
23 
24 FBCALL float fb_CVSFROML( int l )
25 {
26  hDoCVn( l, float, 4 );
27 }
28 
29 FBCALL int fb_CVLFROMS( float f )
30 {
31  hDoCVn( f, int, 4 );
32 }
33 
34 FBCALL long long fb_CVLONGINTFROMD( double d )
35 {
36  hDoCVn( d, long long, 8 );
37 }