Minimum and Maximum real values

284 views
Skip to first unread message

Luigi Ferraris

unread,
Dec 21, 2025, 8:06:58 AM12/21/25
to Harbour Users
Hi friends,
I need the maximum real positive and maximum real negative values (that Harbour know) to use as limits.
I'm able to create a wrapper C functions but I'm not able to choose between defined values (see include\hbdefs.h) e.g.LONGLONG_MAX and LONGLONG_MIN
Any info is appreciated, best regards
Luigi

alex;

unread,
Dec 23, 2025, 11:09:23 AM12/23/25
to Harbour Users
Hello, Luigi. What is the question. It probably depends on the settings. We need to check how it works on different operating systems.

#if defined( HB_OS_WIN )
   #if defined( HB_OS_WIN_64 )
      #undef HB_LONG_LONG_OFF
   #endif
#endif

#if defined( HB_OS_WIN_64 )
#  define HB_ARCH_64BIT
#elif ULONG_MAX > UINT_MAX && UINT_MAX > USHRT_MAX
#  define HB_ARCH_64BIT
#elif ULONG_MAX == UINT_MAX && UINT_MAX > USHRT_MAX
#  define HB_ARCH_32BIT
#elif ULONG_MAX > UINT_MAX && UINT_MAX == USHRT_MAX
#  define HB_ARCH_16BIT
#endif

#ifndef HB_LONG_LONG_OFF

   #if defined( HB_OS_WIN ) && ! defined( __GNUC__ )
      typedef __int64            HB_LONGLONG;
      typedef unsigned __int64   HB_ULONGLONG;
   #else
      typedef signed long long   HB_LONGLONG;
      typedef unsigned long long HB_ULONGLONG;
   #endif

   #if ! defined( ULONGLONG_MAX )
      #if defined( _UI64_MAX )
         #define ULONGLONG_MAX      _UI64_MAX
      #elif defined( ULLONG_MAX )
         #define ULONGLONG_MAX      ULLONG_MAX
      #elif defined( ULONG_LONG_MAX )
         #define ULONGLONG_MAX      ULONG_LONG_MAX
      #else
         #define ULONGLONG_MAX      18446744073709551615ULL
      #endif
   #endif
   #if ! defined( LONGLONG_MAX )
      #if defined( _I64_MAX )
         #define LONGLONG_MAX       _I64_MAX
      #elif defined( LLONG_MAX )
         #define LONGLONG_MAX       LLONG_MAX
      #elif defined( LONG_LONG_MAX )
         #define LONGLONG_MAX       LONG_LONG_MAX
      #else
         #define LONGLONG_MAX       9223372036854775807LL
      #endif
   #endif
   #if ! defined( LONGLONG_MIN )
      #if defined( _I64_MIN )
         #define LONGLONG_MIN       _I64_MIN
      #elif defined( LLONG_MIN )
         #define LONGLONG_MIN       LLONG_MIN
      #elif defined( LONG_LONG_MIN )
         #define LONGLONG_MIN       LONG_LONG_MIN
      #else
         #define LONGLONG_MIN       (-LONGLONG_MAX - 1LL)
      #endif
   #endif

#endif /* HB_LONG_LONG_OFF */

Luigi Ferraris

unread,
Dec 31, 2025, 8:01:13 AM (12 days ago) 12/31/25
to Harbour Users
Hi Alex,
sorry for delay but I was busy with my little project to handle Transformation matrix.
I'll explain my request with example.

1) Think about a class to store x,y coordinates and you need to know if internal values was been initialize.
   You cannot use 0,0 because can be the default on the other hand they can be a valid setting.
   Perhaps NIL, but itself is not numeric.
   If I have:
      - hb_MaxPositive() the maximum positive value Harbour can handle
      - hb_MaxNegative() the maximum negative value Harbour can handle
     
   I can use these as "sentinel value" e.g. to answer the question "was setting? Yes or Not"
   
2) Think about you need to find minimum and maximum in a list of x,y
   At the beginning of the procedure, you should probably code (+-)
   maxX := minX := arry[1]:x()    <----
   FOR iK 2 TO ... <----
      maxX := MAX( maxX, arry[ik]:x() )
      minC := MIN( minX, arry[ik]:x() )
   NEXT

   please take a look to the tagged lines

   But I can code without knowing arry size
   maxX := hb_MaxNegative()
   minX := hb_MaxPositive()
   FOR iK 1 TO ... <----
      maxX := MAX( maxX, arry[ik]:x() )
      minX := MIN( minX, arry[ik]:x() )
   NEXT

   
   and I can check using these values as "sentinel"
   min == hb_MaxNegative()
   max == hb_MaxPositive()

Nothing more.
I hope I have explained my intentions and their use.

Greetings to all and Happy New Year
Luigi

alex;

unread,
Jan 2, 2026, 1:09:11 PM (10 days ago) Jan 2
to Harbour Users
Greetings, Luigi.

This means that the HB_ARCH_64BIT flag can be checked in the hb_MaxPositive and hb_MaxNegative functions.
But then I think they should be part of Harbour itself. You're right about that.
Although I may be wrong.

WBR, alex;

Luigi Ferraris

unread,
Jan 2, 2026, 3:13:10 PM (10 days ago) Jan 2
to Harbour Users
Hi Alex.
Yes I think so, must be hb_function I don't know internal but yes to make It portable.
Another use can be
x = log(-15)
If x == hb_maxNegative()
dosomething
Else
Doelse
Endif
But this Is another story
Best regards
Luigi

Luigi Ferraris
www.l3w.it

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/wwkEw0O0m0Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/cd1cf31e-27c2-4f8c-a99a-4e08c559920dn%40googlegroups.com.

alex;

unread,
Jan 3, 2026, 3:17:18 AM (9 days ago) Jan 3
to Harbour Users
Hi, Luigi.
I asked DeepSeek. ))
I hope your browser support translation from russian.
dialog

WBR, alex;
Reply all
Reply to author
Forward
0 new messages