Discussions Search    Reviews    Search Aid    Buzzzz    Google@Omgili Add to iGoogle   Bookmark and Share

  Advanced Search



BUG: numeric_limits<__int64>

On Thu, 3 Jul 2008 06:02:17 +0200, "Adem24" <...@ladem24adem24.com.invalid

VC++6 Bug: numeric_limits<__int64
#include <limitsvoid f()
{
__int64 minval = numeric_limits<__int64 __int64 maxval = numeric_limits<__int64 printf("min=%I64d max=%I64d\n", minval, maxval);
}

/* Output:

min=0 max=0

*/

 Latest discussions from this group  (microsoft.public.vc.language)

WCHAR conversion problem  
[27 Aug 2008]
On Wed, 27 Aug 2008 07:24:01 -0700, Iñaki <Iaki@discussions .microsoft.com Hello everyone...
I need to convert a WCHAR[] to a char* but I don't know how can I do that. I'm not ...
Check if a process is running under the current user (not by using the ...  
[27 Aug 2008]
On Wed, 27 Aug 2008 10:53:43 +0530, Ashutosh <smbs-msdn@nospam .nospam Hi, I am trying...
to check if a process is running under the same credential/user as my application. I can...
using reference as member variable is dangerous?  
[27 Aug 2008]
On Wed, 27 Aug 2008 02:44:03 -0700, George <George@discussio ns.microsoft.com Hello everyone...
For the pattern, using reference variable as internal data member variables, I ...
More...


On Thu, 3 Jul 2008 11:14:59 +0200, "Giovanni Dicanio" <gdicanio@_NOSPAM_email_DOT_it

To add to Carl's correct answer, if you must use VC6, at least I would
suggest to use a better STL implementation than the VC6's default one.

I would suggest STLport to be used with VC6.

HTH,
Giovanni



"Adem24" <...@TK2MSFTNGP03.phx.gbl...


On Wed, 2 Jul 2008 21:57:39 -0700, "Carl Daniel [VC++ MVP]" <...@mvps.org.nospam


VC6 is over 10 years old and has been unsupported for several years now.
Use VC2005 or VC2008, which get this right.

-cd


On Thu, 03 Jul 2008 11:10:30 -0500, Fernando Gómez <...@gmail.com


Just for the record, that would fail in (at least) VC8 if windows.h is
included, since it defines two macros, min and max, so the compiler will
expand numeric_limits<int
Regards.

On Thu, 3 Jul 2008 16:29:24 +0000 (UTC), Joe Greer <...@doubletake.com

Fernando Gmez <...@TK2MSFTNGP05.phx.gbl:


if you code it as (and I know you shouldn't have to do this):

(numeric_limits<__int64
Then it will always work. The normal min/max macros won't be expanded.

joe

On Thu, 3 Jul 2008 18:23:24 +0200, "Giovanni Dicanio" <gdicanio@_NOSPAM_email_DOT_it


"Fernando Gmez" <...@TK2MSFTNGP05.phx.gbl...


#define NOMINMAX

in StdAfx.h


Giovanni


On Thu, 3 Jul 2008 09:30:19 -0700 (PDT), Abdo Haji-Ali <...@gmail.com

On Jul 3, 6:10 pm, Fernando Gómez <...@gmail.comwrote:

The Evil of Macros.
Personally whenever I #include windows.h I #undef min and max
immediately.
Something like this:
#include <windows.h#undef min
#undef max
// Undef any other useless macros here...
#include <limits
Of course you can make a fixed_windows.h file that include the first
three lines and use it instead of windows.h

--
Abdo Haji-Ali
Programmer
In|Framez

On Thu, 3 Jul 2008 22:00:04 +0200, "Adem24" <...@ladem24adem24.com.invalid

"Fernando Gómez" <...@gmail.com
I don't think it is that problem because only numeric_limits<__int64(and unsigned __int64), but the other integral data types work fine.

On Thu, 03 Jul 2008 22:19:57 -0700, Tim Roberts <...@probo.com

"Adem24" <...@ladem24adem24.com.invalid

The STL in VC6 doesn't understand __int64 at all. numeric_limits for
unknown types always returns 0. I'm not sure it can be classified as a
bug.
--
Tim Roberts, tim...@probo.com
Providenza & Boekelheide, Inc.

On Sun, 6 Jul 2008 12:23:13 +0700, "Alan Carre" <...@twilightgames.com

"Tim Roberts" <...@4ax.com...

I was wondering the same thing. How in the hell did that ever compile under
VC6?!? I assumed a typo in the OP. Couldn't be otherwise... or so I thought.
But subsequent followups don't seem to indicate a typo. Very confusing...
essentially the question translates to:

==========================
#include <limitsvoid f()
{
sdfjdslfkjdslfjsdf minval = numeric_limits<sdfjdslfkjdslfjsdf printf("minval = %)odf4rrfrewrvdsfds", minval);
}

Output: "minval = 0"

What is going wrong?
==========================

The question should be "what is going right?" ;)

- Alan Carre


On Sat, 5 Jul 2008 23:08:33 -0700, "Carl Daniel [VC++ MVP]" <...@mvps.org.nospam


No, it's not that at all. VC6 knows that __int64 is a type, there's just no
specialization of std::numeric_limits for that type, so you get the primary
(unspecialized) definition of the template, which returns 0 for min() and
max() as required by the C++ standard (18.2.1.1/2)

-cd


On Sun, 6 Jul 2008 16:22:36 +0700, "Alan Carre" <...@twilightgames.com


Huh. Learn something new every day. And VC6's printf supports "%I64d" as
well? Somehow I thought all this 64 bit stuff was introduced with VC2003. Or
even 2005.

Thanks for setting me straight on that,
- Alan Carre

P.S. I assume then, that VC6 compiles 64 bit arithmetic expressions (32 bit
implementation of course)?

That is...

__int64 llSomeNum1 = 123455767765564554354i64;
__int64 llSomeNum2 = 4454123215456121i64;

if (llSomeNum1 % llSomeNum2 < 2343443423i64) {...} etc...

That kind of thing...

Well, I guess I'll just try it. I should still have VC6 lying around here
somewhere ;)


On Sun, 6 Jul 2008 07:26:03 -0700, "Carl Daniel [VC++ MVP]" <...@mvps.org.nospam


I think the core __int64 support in the compiler may go back to VC4.x or
so - it's been there a while, but not so widely supported by the CRT (so
%I64d might not work - I don't recall). Yes, it's all a library
implementation, with the exception of a few intrinsics that the compiler
does know, e.g. 32bx32b = 64b product - since that's what the hardware
multiply instruction supports directly; likewise for division.

-cd


Discussion Title: BUG: numeric_limits<__int64>
Title Keywords: BUG:  numeric_limits<__int64>