Should I use 'long' instead of 'int' on 64-bits in langs with fixed type size (like Java, C#)

前端 未结 3 1362
伪装坚强ぢ
伪装坚强ぢ 2020-12-20 12:55

In 10, or even 5 years there will be no [Edit2: server or desktop] 32-bit CPUs.

So, are there any advantages in using int (32bit) over

3条回答
  •  自闭症患者
    2020-12-20 13:06

    Sorry for the C++ answer.

    If the size of the type matters use a sized type:

    • uint8_t
    • int32_t
    • int64_t
    • etc

    If the size doesn't matter use an expressive type:

    • size_t
    • ptrdiff_t
    • ssize_t
    • etc

    I know that D has sized types and size_t. I'm not sure about Java or C#.

提交回复
热议问题