Thread overview
Integer types
October 08

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

October 08

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.

October 08

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.

October 09

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

October 09

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.