-
found it.
Hi
I was able to find the answer to this problem. Just in case someone encounters
this same problem, you must use "%I64u" as a format specifier instead of
"%I64d".
"marcsto" <marcsto@yahoo.com> wrote:
>
>I thought so too, but I am not a c++ programmer and I have no idea how those
>flags work. I have been looking all over the net and still havn't found
any
>other flag then %I64d. If anyone has any other flag I could try, it would
>be greatly appreciated. Thanks.
>
>Danny Kalev <dannykk@inter.net.il> wrote:
>>I'm, not an expert on the all the VB mess involved but there must be a
>>format flag similar to %I64d that represents unsigned __int64. You
>>should use it instead of %I64d.
>>
>>Danny
>>
>>marcsto wrote:
>>>
>>> Hello
>>>
>>> I am getting an extreamly weird problem involving a conversion from 64
>bit
>>> unsigned int to a string. Here's what I do:
>>>
>>> unsigned __int64 TempNum;
>>> TempNum = 9223372036854775808;
>>> char num[40] = {0}; // initialize buffer to binary zeros
>>> sprintf(num, "%I64d", TempNum); // convert n to string
>>> BSTR Stogy;
>>> Stogy = (BSTR)num; //Convert number so it can be accessed by vb
>>> return(SysAllocString(Stogy));
>>>
>>> Anyways, that's pretty much what's happening. Now, here's the problem...
>>> when tempnum is equal to a number smaller then 9223372036854775808, it
>works
>>> fine. But when tempnum = 9223372036854775808 then the value returned
is
>-9223372036854775808.
>>> When tempnum = 9223372036854775809, the value returned is -9223372036854775807.
>>>
>>> I'm not too sure of what is happening although I think it has something
>to
>>> do with the fact that 9223372036854775808 in binary is 10000000000000...
>>> It may also have something to do with the %I64d used in the sprintf function.
>>> Can any one please help me with this? I would appreciate any incite you
>may
>>> have on this problem.
>>> Thank you very much!
>>> Marc
>
-
Re: found it.
Note that neither of these flags is standard. It's a VC++ specific
extension. Therefore, you couldn't find documentation on it.
Danny
marcsto wrote:
>
> Hi
>
> I was able to find the answer to this problem. Just in case someone encounters
> this same problem, you must use "%I64u" as a format specifier instead of
> "%I64d".
>
> "marcsto" <marcsto@yahoo.com> wrote:
> >
> >I thought so too, but I am not a c++ programmer and I have no idea how those
> >flags work. I have been looking all over the net and still havn't found
> any
> >other flag then %I64d. If anyone has any other flag I could try, it would
> >be greatly appreciated. Thanks.
> >
> >Danny Kalev <dannykk@inter.net.il> wrote:
> >>I'm, not an expert on the all the VB mess involved but there must be a
> >>format flag similar to %I64d that represents unsigned __int64. You
> >>should use it instead of %I64d.
> >>
> >>Danny
> >>
> >>marcsto wrote:
> >>>
> >>> Hello
> >>>
> >>> I am getting an extreamly weird problem involving a conversion from 64
> >bit
> >>> unsigned int to a string. Here's what I do:
> >>>
> >>> unsigned __int64 TempNum;
> >>> TempNum = 9223372036854775808;
> >>> char num[40] = {0}; // initialize buffer to binary zeros
> >>> sprintf(num, "%I64d", TempNum); // convert n to string
> >>> BSTR Stogy;
> >>> Stogy = (BSTR)num; //Convert number so it can be accessed by vb
> >>> return(SysAllocString(Stogy));
> >>>
> >>> Anyways, that's pretty much what's happening. Now, here's the problem...
> >>> when tempnum is equal to a number smaller then 9223372036854775808, it
> >works
> >>> fine. But when tempnum = 9223372036854775808 then the value returned
> is
> >-9223372036854775808.
> >>> When tempnum = 9223372036854775809, the value returned is -9223372036854775807.
> >>>
> >>> I'm not too sure of what is happening although I think it has something
> >to
> >>> do with the fact that 9223372036854775808 in binary is 10000000000000...
> >>> It may also have something to do with the %I64d used in the sprintf function.
> >>> Can any one please help me with this? I would appreciate any incite you
> >may
> >>> have on this problem.
> >>> Thank you very much!
> >>> Marc
> >
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks