diff --git a/harbour/ChangeLog b/harbour/ChangeLog index bfc33ba00b..c77659c37d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-11-26 18:22 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/itemapi.c + * changed hb_itemPutNLen() function to create integer item only + when conversion to HB_LONG does not change value of passed double + argument. It fixes some problems like restoring non integer double + values with 0 decimal places by __MVRESTORE() + + * harbour/source/rtl/val.c + % minor optimization + 2008-11-25 09:15 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/gtwvg/wvggui.c * harbour/contrib/gtwvg/wvgdlg.prg diff --git a/harbour/source/rtl/val.c b/harbour/source/rtl/val.c index 62db2cfb1c..5bfe0f1da5 100644 --- a/harbour/source/rtl/val.c +++ b/harbour/source/rtl/val.c @@ -72,7 +72,7 @@ HB_FUNC( VAL ) if( !fDbl ) hb_retnintlen( lValue, iWidth ); else - hb_retnlen( dValue, iWidth, iDec ); + hb_retndlen( dValue, iWidth, iDec ); } else hb_errRT_BASE_SubstR( EG_ARG, 1098, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index 9766dde45b..5ec5539913 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -956,18 +956,24 @@ PHB_ITEM hb_itemPutNLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec ) if( iDec < 0 ) iDec = hb_stackSetStruct()->HB_SET_DECIMALS; - if( iDec > 0 ) - return hb_itemPutNDLen( pItem, dNumber, iWidth, iDec ); - else if( HB_DBL_LIM_INT( dNumber ) ) - return hb_itemPutNILen( pItem, ( int ) dNumber, iWidth ); - else if( HB_DBL_LIM_LONG( dNumber ) ) + if( iDec == 0 ) + { + HB_LONG lNumber = ( HB_LONG ) dNumber; + + if( ( double ) lNumber == dNumber ) + { + if( HB_LIM_INT( lNumber ) ) + return hb_itemPutNILen( pItem, ( int ) lNumber, iWidth ); + else #ifdef HB_LONG_LONG_OFF - return hb_itemPutNLLen( pItem, ( long ) dNumber, iWidth ); + return hb_itemPutNLLen( pItem, ( long ) lNumber, iWidth ); #else - return hb_itemPutNLLLen( pItem, ( LONGLONG ) dNumber, iWidth ); + return hb_itemPutNLLLen( pItem, ( LONGLONG ) lNumber, iWidth ); #endif - else - return hb_itemPutNDLen( pItem, dNumber, iWidth, 0 ); + } + } + + return hb_itemPutNDLen( pItem, dNumber, iWidth, iDec ); } PHB_ITEM hb_itemPutNDLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec )