回覆列表
  • 1 # 手機使用者82497028241

    參見:Implicit conversions

    摘錄:

    Real floating-integer conversionsA finite value of any real floating type can be implicitly converted to any integer type. Except where covered by boolean conversion above, the rules are: The fractional part is discarded (truncated towards zero). If the resulting value can be represented by the target type, that value is used otherwise, the behavior is undefined

    翻譯:

    浮點型轉化為整型(除了_Bool型別。轉化為_Bool時沒有向0取整的過程,而是直接比較其是不是0)的規則是:

    先向零取整,如果取整後的結果能被目標整型容納,那一切OK;若不能,則屬於未定義行為。

  • 中秋節和大豐收的關聯?
  • 感冒能喝紅糖生薑水嗎?