www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Integer types

reply Jared McKinnan <jmk email.com> writes:
Hello there,

Just wanted to ask if there's a real difference between e.g. the 
"long" type and "int_fast64_t" in terms of execution times.

Thanks
Oct 08
next sibling parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Tuesday, 8 October 2024 at 15:57:24 UTC, Jared McKinnan wrote:
 Hello there,

 Just wanted to ask if there's a real difference between e.g. 
 the "long" type and "int_fast64_t" in terms of execution times.

 Thanks
You need to specify your platform. In most cases, no, you won't see a difference. It exists so that if the platform has faster arithmetic for a certain size, it can choose that size.
Oct 08
parent Jared McKinnan <jmk email.com> writes:
On Tuesday, 8 October 2024 at 16:39:26 UTC, Imperatorn wrote:
 On Tuesday, 8 October 2024 at 15:57:24 UTC, Jared McKinnan 
 wrote:
 Hello there,

 Just wanted to ask if there's a real difference between e.g. 
 the "long" type and "int_fast64_t" in terms of execution times.

 Thanks
You need to specify your platform. In most cases, no, you won't see a difference. It exists so that if the platform has faster arithmetic for a certain size, it can choose that size.
I using Windows 10 x64.
Oct 08
prev sibling parent reply Salih Dincer <salihdb hotmail.com> writes:
On Tuesday, 8 October 2024 at 15:57:24 UTC, Jared McKinnan wrote:
 Hello there,

 Just wanted to ask if there's a real difference between e.g. 
 the "long" type and "int_fast64_t" in terms of execution times.

 Thanks
```int_fast64_t``` is the fastest 64-bit or larger integer type. The type that is at least 64 bits long and works fastest on the platform is selected. This type can be selected if performance is more important than memory and the processor can run faster on certain types. ```long``` is an integer that is strictly 64 bits long. That is, this type is permanently 64 bits and provides cross-platform portability. If you want strictly 64 bits and care about cross-platform consistency, you should use this type. So you have to choose between consistency and efficiency. When you tell the compiler this choice, it implements it if it can agree with the processor. SDB 79
Oct 09
parent Jared McKinnan <jmk email.com> writes:
On Wednesday, 9 October 2024 at 12:12:22 UTC, Salih Dincer wrote:
 [...]

 ```int_fast64_t``` is the fastest 64-bit or larger integer 
 type. The type that is at least 64 bits long and works fastest 
 on the platform is selected. This type can be selected if 
 performance is more important than memory and the processor can 
 run faster on certain types.

 ```long``` is an integer that is strictly 64 bits long. That 
 is, this type is permanently 64 bits and provides 
 cross-platform portability. If you want strictly 64 bits and 
 care about cross-platform consistency, you should use this type.

 So you have to choose between consistency and efficiency. When 
 you tell the compiler this choice, it implements it if it can 
 agree with the processor.

 SDB 79
Thank you. That helps.
Oct 09