Jump to page: 1 2
Thread overview
ulong is not 64 bit long?
Oct 17, 2005
Tiago Gasiba
Oct 17, 2005
Don Clugston
Oct 17, 2005
Tiago Gasiba
Oct 17, 2005
Walter Bright
Oct 17, 2005
Tiago Gasiba
Oct 17, 2005
Oskar Linde
Oct 17, 2005
JT
Oct 17, 2005
Ivan Senji
Oct 17, 2005
JT
Oct 17, 2005
JT
Oct 17, 2005
Ivan Senji
Oct 17, 2005
Ameer Armaly
Oct 18, 2005
Sean Kelly
Oct 19, 2005
Tiago Gasiba
Oct 19, 2005
Sean Kelly
October 17, 2005
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
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
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
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
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
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
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
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
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
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?
« First   ‹ Prev
1 2