Thread overview | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 17, 2005 ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Hi all, Is ulong 64bit or not? I'm SuSE 10.0 on a 32bit machine. On this page [http://www.digitalmars.com/d/type.html] we can see that ulong should be 64bit long. With gcc we have the unsigned long long which, although the machine might not be true 64bit, the data type is still 64 bit. i.e. gcc compiles correctly on a 64bit machine and fakes on a 32bit machine. Why is ulong.max only 2^32-1 ?? Is this a bug? Thanks! Best Regards, Tiago Gasiba -- Tiago Gasiba (MSc.) - http://www.gasiba.de Everything should be made as simple as possible, but not simpler. |
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tiago Gasiba | Tiago Gasiba wrote:
> Hi all,
>
> Is ulong 64bit or not?
> I'm SuSE 10.0 on a 32bit machine. On this page
> [http://www.digitalmars.com/d/type.html] we can see that ulong should be
> 64bit long.
> With gcc we have the unsigned long long which, although the machine might
> not be true 64bit, the data type is still 64 bit.
> i.e. gcc compiles correctly on a 64bit machine and fakes on a 32bit
> machine.
> Why is ulong.max only 2^32-1 ?? Is this a bug?
> Thanks!
ulong is definitely 64 bits, it's faked on 32 bit CPUs.
ulong.max == 2^64-1 on DMD - WinXP.
Are you using DMD-Linux or DMC ?
|
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | Hi! I'm using dmd on Linux with "gcc (GCC) 4.0.2 20050901 (prerelease)(SUSE Linux)" and D version is Digital Mars D Compiler v0.136 Here it goes: test.d: ------- code ------- import std.c.stdio; import std.c.stdlib; int main( ){ printf("%lu\n",ulong.max); return 0; } ------- code ------- dmd -w test.d ./test 4294967295 (answer = 2^32-1 !!!) Even worse is this: ------- code ------- import std.c.stdio; import std.c.stdlib; int main( ){ ulong X = 0xffff000000000000L; printf("%lu\n",X); return 0; } ------- code ------- dmd test.d - no compiler errors ./test 0 (answer = 0!!!) Thanks, Tiago Don Clugston wrote: > Tiago Gasiba wrote: >> Hi all, >> >> Is ulong 64bit or not? >> I'm SuSE 10.0 on a 32bit machine. On this page >> [http://www.digitalmars.com/d/type.html] we can see that ulong should be >> 64bit long. >> With gcc we have the unsigned long long which, although the machine >> might >> not be true 64bit, the data type is still 64 bit. >> i.e. gcc compiles correctly on a 64bit machine and fakes on a 32bit >> machine. >> Why is ulong.max only 2^32-1 ?? Is this a bug? >> Thanks! > > ulong is definitely 64 bits, it's faked on 32 bit CPUs. > ulong.max == 2^64-1 on DMD - WinXP. > Are you using DMD-Linux or DMC ? -- Tiago Gasiba (MSc.) - http://www.gasiba.de Everything should be made as simple as possible, but not simpler. |
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tiago Gasiba | Use %llu to print a C "long long", which is the equivalent of a D "long". %lu will print a C "long", which is only 32 bits. Or, use std.stdio.writefln(X). |
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | So, everything works fine now, even printf("%llu\n",ulong.max), of course! Or, better said, it allways worked fine :) ... Thanks! Tiago Gasiba (MSc.) - http://www.gasiba.de Everything should be made as simple as possible, but not simpler. |
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | In article <dj0g9l$elk$1@digitaldaemon.com>, Walter Bright says... >Use %llu to print a C "long long", which is the equivalent of a D "long". %lu will print a C "long", which is only 32 bits. Or, use std.stdio.writefln(X). Isn't it time to replace printf by writef et.al. as default imported symbols, or remove the default import of printf? /Oskar |
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oskar Linde | No. That would be a Very Bad Idea.
Oskar Linde wrote:
>
> Isn't it time to replace printf by writef et.al. as default imported symbols, or
> remove the default import of printf?
>
> /Oskar
>
>
|
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to JT | JT wrote: > No. That would be a Very Bad Idea. > Why? I think it would be a great idea. > > Oskar Linde wrote: > >> >> Isn't it time to replace printf by writef et.al. as default imported symbols, or >> remove the default import of printf? >> >> /Oskar >> >> |
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ivan Senji | Because they are very different creatures. Just because you have no need for printf doesnt mean you should take it away from me. You are basically talking about 'censoring' portions of the standard c libraries. huh?
Ivan Senji wrote:
> JT wrote:
>
>> No. That would be a Very Bad Idea.
>>
>
> Why? I think it would be a great idea.
>
>>
>> Oskar Linde wrote:
>>
>>>
>>> Isn't it time to replace printf by writef et.al. as default imported symbols, or
>>> remove the default import of printf?
>>>
>>> /Oskar
>>>
>>>
|
October 17, 2005 Re: ulong is not 64 bit long? | ||||
---|---|---|---|---|
| ||||
Posted in reply to JT | No, I think he just means making it so printf has to be imported (like every other C function) which is not the case currently (since it is automatically imported/defined in object.d.)
-[Unknown]
> Because they are very different creatures. Just because you have no need for printf doesnt mean you should take it away from me. You are basically talking about 'censoring' portions of the standard c libraries. huh?
|
Copyright © 1999-2021 by the D Language Foundation