Something wrong with std.math.pow?

Jesse Phillips jessekphillips+D at gmail.com
Fri Sep 28 07:23:53 PDT 2012


On Friday, 28 September 2012 at 05:35:13 UTC, Jesse Phillips 
wrote:
> Specifically, shouldn't 2^48 be a little bit larger than 0?

After heading to bed I realized that I could no longer rely on 
compile-time type selection since I was calling a function. So 
obviously the number I was looking for would not fit into an int.

import std.conv;
import std.math;

void main() {
     pragma(msg, "Number of bits: " ~ to!string(12 * 4));
     pragma(msg, "Addressable Bytes: " ~ to!string(pow(2UL, 12 * 
4)));
}

Number of bits: 48
Addressable Bytes: 281474976710656

Much better.


More information about the Digitalmars-d-learn mailing list