From ba857aef68df980eeeac3225db024107d9b652fe Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Wed, 4 Aug 1999 04:32:25 +0000 Subject: [PATCH] See ChangeLog entry 19990804-00:15 EDT David G. Holm --- harbour/ChangeLog | 8 ++++++++ harbour/source/rtl/math.c | 6 ++++++ harbour/source/vm/hvm.c | 8 ++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4baf9a631b..bbc20ba0cf 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +19990804-00:15 EDT David G. Holm + * source/rtl/math.c + ! Corrected MOD() to set the correct number of decimal points. + * source/vm/hvm.c + ! Corrected Div() to set the correct number of decimal points. + ! Corrected Modulus() to use fmod() instead of the % operator. + ! Corrected Modulus() to set the correct number of decimal points. + 19990803-22:10 EDT David G. Holm * source/rtl/setcolor.c + Added missing '#ifdef HARBOUR_USE_GTAPI'. diff --git a/harbour/source/rtl/math.c b/harbour/source/rtl/math.c index 80b65282cc..16b2da3229 100644 --- a/harbour/source/rtl/math.c +++ b/harbour/source/rtl/math.c @@ -244,9 +244,15 @@ FUNCTION MOD(cl_num, cl_base) hb_retnd(dResult + dBase); else hb_retnd(dResult); + /* Always set default number of decimals after computing mod */ + stack.Return.item.asDouble.decimal = hb_set.HB_SET_DECIMALS; } else + { hb_retnd(dNumber); + /* Set the correct number of decimals */ + stack.Return.item.asDouble.decimal = (pNumber->item.asDouble.decimal); + } } else { diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index bf0654cfdf..1ddf045d77 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -702,7 +702,9 @@ void Div( void ) double d2 = PopDouble( &wDec2 ); double d1 = PopDouble( &wDec1 ); - PushNumber( d1 / d2, (wDec1>wDec2) ? wDec1 : wDec2 ); + /* NOTE: Clipper always returns the result of a division + with the SET number of decimal places. */ + PushNumber( d1 / d2, hb_set.HB_SET_DECIMALS ); } void Do( WORD wParams ) @@ -1346,7 +1348,9 @@ void Modulus( void ) double d2 = PopDouble( &wDec2 ); double d1 = PopDouble( &wDec1 ); - PushNumber( ( long ) d1 % ( long ) d2, (wDec1>wDec2) ? wDec1 : wDec2 ); + /* NOTE: Clipper always returns the result of modulus + with the SET number of decimal places. */ + PushNumber( fmod( d1, d2 ), hb_set.HB_SET_DECIMALS ); } void Mult( void )