Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
April 17, 2014 Size_t on x86 is uint,on x64 is ulong,it's a good thing? | ||||
---|---|---|---|---|
| ||||
Size_t on x86 is uint,on x64 is ulong,it's a good thing? I don't think is ok. it creates many convert thing,such as length is ulong ,must cast to int or cast to uint. It will be waste of time ,I think. |
April 17, 2014 Re: Size_t on x86 is uint,on x64 is ulong,it's a good thing? | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLike | On Thursday, 17 April 2014 at 16:36:29 UTC, FrankLike wrote:
> Size_t on x86 is uint,on x64 is ulong,it's a good thing?
>
> I don't think is ok.
> it creates many convert thing,such as length is ulong ,must cast to int or cast to uint. It will be waste of time ,I think.
It's the same in C and it reflects what the hardware is doing underneath with regard to memory addresses. That's the point of size_t. If it didn't change size then we'd all just use ulong or uint for all our array lengths etc.
|
April 17, 2014 Re: Size_t on x86 is uint,on x64 is ulong,it's a good thing? | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLike | On 4/17/2014 12:36 PM, FrankLike wrote:
> Size_t on x86 is uint,on x64 is ulong,it's a good thing?
>
> I don't think is ok.
> it creates many convert thing,such as length is ulong ,must cast to
> int or cast to uint. It will be waste of time ,I think.
>
>
If you want fixed-length, you use uint/ulong/etc. The whole point of size_t is for when you need the hardware's native data size.
|
April 18, 2014 Re: Size_t on x86 is uint,on x64 is ulong,it's a good thing? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | On Thursday, 17 April 2014 at 16:46:15 UTC, John Colvin wrote:
> On Thursday, 17 April 2014 at 16:36:29 UTC, FrankLike wrote:
>> Size_t on x86 is uint,on x64 is ulong,it's a good thing?
>>
>> I don't think is ok.
>> it creates many convert thing,such as length is ulong ,must cast to int or cast to uint. It will be waste of time ,I think.
>
> It's the same in C and it reflects what the hardware is doing underneath with regard to memory addresses. That's the point of size_t. If it didn't change size then we'd all just use ulong or uint for all our array lengths etc.
Thank you,I think 'use uint' is better than 'use ulong' .
You know that 'point.x,point.y' is int ,on x64 ,no change,
'length' keeps the same to 'point.x,point.y' ,maybe a good thing.
Frank.
|
April 18, 2014 Re: Size_t on x86 is uint,on x64 is ulong,it's a good thing? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin |
> It's the same in C and it reflects what the hardware is doing underneath with regard to memory addresses. That's the point of size_t. If it didn't change size then we'd all just use ulong or uint for all our array lengths etc.
In c#,add the new attribute 'longlength' on the new version,keep the ‘length' in the attributes,and the type 'int' or 'uint' that is ok for most of condition ,maybe a longlength is ok for a little condition.
Thank you.
Frank
|
April 18, 2014 Re: Size_t on x86 is uint,on x64 is ulong,it's a good thing? | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLIKE | On Friday, 18 April 2014 at 00:31:20 UTC, FrankLIKE wrote:
> Thank you,I think 'use uint' is better than 'use ulong' .
> You know that 'point.x,point.y' is int ,on x64 ,no change,
> 'length' keeps the same to 'point.x,point.y' ,maybe a good thing.
>
> Frank.
You are only supposed to use `size_t` (and `ptrdiff_t`) for things that represent pointer indexing, pointer offsets, or their genral abstractions (indexing a slice, getting the length of a range...).
If you want to store "just a number", then select an integral type with pre-defined size.
|
Copyright © 1999-2021 by the D Language Foundation