std.conv.to vs. casting

monarch_dodra monarchdodra at gmail.com
Thu Jul 4 12:28:26 PDT 2013


On Thursday, 4 July 2013 at 16:16:08 UTC, Ali Çehreli wrote:
> On 07/04/2013 03:15 AM, Joseph Rushton Wakeling wrote:
>
> > The cast should be safe, as it's a size_t to a double.
>
> I am commenting without fully understanding the context: Both 
> size_t and double are 64 bit types on a 64-bit system. 
> double.mant_dig being 53, converting from size_t to double 
> loses information for many values.

It's not about losing information, it's about being out of range.

For example, to!float(2.0^^50) will throw an exception.


More information about the Digitalmars-d-learn mailing list