From d|pter|x@w@ng @end|ng |rom gm@||@com  Thu Aug 12 06:50:47 2021
From: d|pter|x@w@ng @end|ng |rom gm@||@com (Dipterix Wang)
Date: Thu, 12 Aug 2021 00:50:47 -0400
Subject: [Rd] Double to uint64_t on M1
In-Reply-To: <C582D4F5-6218-42CC-AC63-50CAB13D977E@R-project.org>
References: <EE649952-4BB6-432A-B3CA-BD9B11DD9324@gmail.com>
 <C582D4F5-6218-42CC-AC63-50CAB13D977E@R-project.org>
Message-ID: <FCD86C45-A75A-47FC-BAA6-ACBB4FD16892@gmail.com>

Thank you,

I guess I should convert double to uint64_t instead of int64_t...

The reason why I asked is because bit64 package `bit64::as.integer64(2^63)` produces different results on my machine vs. another server. This package converts double to int64_t directly. Looks like this is a bug in their package.

Thanks!

Best,

- Dipterix

> On Aug 11, 2021, at 11:52 PM, Simon Urbanek <simon.urbanek at R-project.org> wrote:
> 
> hing to do with R. 2^63 is too large to be represented as singed integer, so the behavior is undefined - to quote from the C99 specs (6.3.1.4):
> 
> "If the value of the integral part cannot be represented by the integer type, the behavior is undefined."
> 
> Your subject doesn't match your question as the uint64_t conversion is well-defined and the same on both platforms, but the conversion to int64_t in undefined


	[[alternative HTML version deleted]]



[Rd] Double to uint64_t on M1
Dipterix Wang