Page 2 of 2
Re: Bug en los operadores fwh2409 xharbour 64 bits
Posted: Sun Jan 19, 2025 8:06 am
by Antonio Linares
/* converts a numeric to a string with optional width & precision.
This function should be used by any function that wants to format numeric
data for displaying, printing, or putting in a database.
Note: The caller is responsible for calling hb_xfree to free the results
buffer, but ONLY if the return value is not a NULL pointer! (If a NULL
pointer is returned, then there was a conversion error.)
*/
char * hb_itemStr( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec )
Re: Bug en los operadores fwh2409 xharbour 64 bits
Posted: Sun Jan 19, 2025 8:26 am
by Antonio Linares
Getting closer:
/* converts a numeric to a padded string iSize length and iDec number
of digits after dot.
Note: szResult has to be at least iSize + 1 length.
*/
BOOL hb_itemStrBuf( char * szResult, PHB_ITEM pNumber, int iSize, int iDec )
...
/* Set to asterisks in case of overflow */
if( iPos < 0 )
{
memset( szResult, '*', iSize );
return FALSE;
}
Re: Bug en los operadores fwh2409 xharbour 64 bits
Posted: Sun Jan 19, 2025 8:58 am
by Antonio Linares
We have to compare Harbour and xHarbour source code on:
BOOL hb_itemStrBuf( char * szResult, PHB_ITEM pNumber, int iSize, int iDec )
as xHarbour reports the number is NOT finite and thus the "*":
Code: Select all | Expand
function Main()
Test( 2032212 / 30 * 30, 50, 2 )
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <hbapiitm.h>
#include <stdio.h>
#define HB_FINITE_DBL( d ) ( _finite( d ) != 0 )
HB_FUNC( TEST )
{
PHB_ITEM pNumber = hb_param( 1, HB_IT_DOUBLE );
char buffer[ 100 ];
OutputDebugString( hb_itemStr( hb_param( 1, HB_IT_DOUBLE ),
hb_param( 2, HB_IT_NUMERIC ), hb_param( 3, HB_IT_NUMERIC ) ) );
sprintf (buffer, "%i", (int) pNumber->item.asDouble.length );
OutputDebugString( buffer );
if( HB_FINITE_DBL( hb_parnd( 1 ) ) )
OutputDebugString( "Finite" );
else
OutputDebugString( "Not finite" );
}
#pragma ENDDUMP
Re: Bug en los operadores fwh2409 xharbour 64 bits
Posted: Sun Jan 19, 2025 3:17 pm
by Antonio Linares
Bug solucionado ?
Dear Enrico,
Could you please modify this on xHarbour source code ?
xharbour/source/vm/itemapi.c
on line 1426:
#if defined( __RSXNT__ ) || defined( __EMX__ ) || \
defined( __XCC__ ) || defined( __POCC__ ) || defined( __DMC__ ) || \
defined( HB_OS_HPUX )
# define HB_FINITE_DBL( d ) ( isfinite( d ) != 0 )
#elif defined( __clang__ )
# define HB_FINITE_DBL( d ) ( isfinite( d ) != 0 )
#elif defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || defined( _MSC_VER )
# define HB_FINITE_DBL( d ) ( _finite( d ) != 0 )
#elif defined(__APPLE__)
# define HB_FINITE_DBL( d ) ( isfinite( d ) != 0 )
#elif defined( __GNUC__ ) || defined( __DJGPP__ ) || defined( __MINGW32__ ) || \
defined( __LCC__ )
# define HB_FINITE_DBL( d ) ( finite( d ) != 0 )
Please build xHarbour 64 with this change and lets test your example
Re: Bug en los operadores fwh2409 xharbour 64 bits
Posted: Sun Jan 19, 2025 6:18 pm
by Enrico Maria Giordano
Re: Bug en los operadores fwh2409 xharbour 64 bits
Posted: Sun Jan 19, 2025 10:53 pm
by leandro