From 1192b4ac32865499fc89be05fbbf8326350c453d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 21 Jun 2009 10:55:59 +0000 Subject: [PATCH] 2009-06-21 12:55 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/rtl/binnumx.c * contrib/xpp/binnumx.c + Added F2BIN() and BIN2F() Xbase++ functions. Code is the same as FTOC() and CTOF() in hbct. --- harbour/ChangeLog | 6 ++++++ harbour/contrib/xpp/binnumx.c | 21 +++++++++++++++++++++ harbour/source/rtl/binnumx.c | 21 +++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 99b32582ef..9fd2ba664b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-21 12:55 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * source/rtl/binnumx.c + * contrib/xpp/binnumx.c + + Added F2BIN() and BIN2F() Xbase++ functions. + Code is the same as FTOC() and CTOF() in hbct. + 2009-06-21 12:48 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbxbp/xbp.ch + Fixed non-debug branch to work in both normal code and codeblocks. diff --git a/harbour/contrib/xpp/binnumx.c b/harbour/contrib/xpp/binnumx.c index 63749ad9b4..4989b17f1f 100644 --- a/harbour/contrib/xpp/binnumx.c +++ b/harbour/contrib/xpp/binnumx.c @@ -89,3 +89,24 @@ HB_FUNC( W2BIN ) HB_PUT_LE_UINT16( szResult, uiValue ); hb_retclen( szResult, 4 ); } + +HB_FUNC( F2BIN ) +{ + char buf[ sizeof( double ) ]; + double d = hb_parnd( 1 ); + + HB_PUT_LE_DOUBLE( buf, d ); + hb_retclen( buf, sizeof( buf ) ); +} + +HB_FUNC( BIN2F ) +{ + if( hb_parclen( 1 ) >= sizeof( double ) ) + { + const char * buf = hb_parc( 1 ); + + hb_retnd( HB_GET_LE_DOUBLE( buf ) ); + } + else + hb_retnd( 0.0 ); +} diff --git a/harbour/source/rtl/binnumx.c b/harbour/source/rtl/binnumx.c index 2431b8fda7..f504ff8c69 100644 --- a/harbour/source/rtl/binnumx.c +++ b/harbour/source/rtl/binnumx.c @@ -94,4 +94,25 @@ HB_FUNC( W2BIN ) hb_retclen( szResult, 4 ); } +HB_FUNC( F2BIN ) +{ + char buf[ sizeof( double ) ]; + double d = hb_parnd( 1 ); + + HB_PUT_LE_DOUBLE( buf, d ); + hb_retclen( buf, sizeof( buf ) ); +} + +HB_FUNC( BIN2F ) +{ + if( hb_parclen( 1 ) >= sizeof( double ) ) + { + const char * buf = hb_parc( 1 ); + + hb_retnd( HB_GET_LE_DOUBLE( buf ) ); + } + else + hb_retnd( 0.0 ); +} + #endif