Hi all,

I have changed the numeric comparison functions in my Harbour version to compensate for floating point issues when comparing numeric values (it was must simpler doing it in Harbour than in the PRG code) - I round all values to 8 decimal places before making the comparison - I have used this for years with many Harbour builds with MSVC v6.

I am trying MS Visual Studio 2005 (MSVC v8?) but there seems to be an issue with my changes as they relate to hb_numRound. For example, my hb_vmExactlyEqual() code was changed from:

else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
    hb_vmPushLogical( hb_vmPopNumber() == hb_vmPopNumber() );

...to this...

else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
{
   double dNumber2 = hb_vmPopNumber();
   double dNumber1 = hb_vmPopNumber();
dNumber1 = hb_numRound( dNumber1, (int) MY_PRECISION ); // MY_PRECISION is defined as 8 dNumber2 = hb_numRound( dNumber2, (int) MY_PRECISION ); // MY_PRECISION is defined as 8
   hb_vmPushLogical( dNumber1 == dNumber2 );
}

Again, this works fine in MSVC v6 but the following PRG code fails if I build this using VS 2005:

? 3.2 == 3.2  // returns .T. in MSVC v6 and .F. in VS 2005.

If I remove the calls to hn_numRound() as...

else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
{
   double dNumber2 = hb_vmPopNumber();
   double dNumber1 = hb_vmPopNumber();
// dNumber1 = hb_numRound( dNumber1, (int) MY_PRECISION );
// dNumber2 = hb_numRound( dNumber2, (int) MY_PRECISION );
   hb_vmPushLogical( dNumber1 == dNumber2 );
}

...it works ok.

Can anyone tell my why there is a difference between these 2 C versions?

TIA.

Regards,
Randy.


_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to