This progam:
import std.math;
import std.stdio;
import std.typetuple;
ulong log2(ulong n)
{
return n == 1 ? 0
: 1 + log2(n / 2);
}
void print(ulong value)
{
writefln(%s: %s %s, value, log2(value), std.math.log2(value));
}
void main()
{
foreach(T; TypeTuple!(byte,
Jonathan M Davis:
This progam:
import std.math;
import std.stdio;
import std.typetuple;
ulong log2(ulong n)
{
return n == 1 ? 0
: 1 + log2(n / 2);
}
void print(ulong value)
{
writefln(%s: %s %s, value, log2(value), std.math.log2(value));
}
void
Do you know why is this program:
import std.stdio;
void main() {
real r = 9223372036854775808UL;
writefln(%1.19f, r);
}
Printing:
9223372036854775807.800
Instead of this?
9223372036854775808.000
Bye,
bearophile
On 04/04/12 13:40, bearophile wrote:
Jonathan M Davis:
This progam:
import std.math;
import std.stdio;
import std.typetuple;
ulong log2(ulong n)
{
return n == 1 ? 0
: 1 + log2(n / 2);
}
void print(ulong value)
{
writefln(%s: %s %s, value, log2(value),
On 04/04/2012 05:15 PM, Don Clugston wrote:
I don't think so. For 80-bit reals, every long can be represented
exactly in an 80 bit real, as can every ulong from 0 up to and including
ulong.max - 1. The only non-representable built-in integer is ulong.max,
which (depending on rounding mode) gets
On 04/04/2012 01:46 PM, bearophile wrote:
Do you know why is this program:
import std.stdio;
void main() {
real r = 9223372036854775808UL;
writefln(%1.19f, r);
}
Printing:
9223372036854775807.800
Instead of this?
9223372036854775808.000
Bye,
On 04/04/12 18:53, Timon Gehr wrote:
On 04/04/2012 05:15 PM, Don Clugston wrote:
I don't think so. For 80-bit reals, every long can be represented
exactly in an 80 bit real, as can every ulong from 0 up to and including
ulong.max - 1. The only non-representable built-in integer is ulong.max,
On 04/04/12 13:46, bearophile wrote:
Do you know why is this program:
import std.stdio;
void main() {
real r = 9223372036854775808UL;
writefln(%1.19f, r);
}
Printing:
9223372036854775807.800
Instead of this?
9223372036854775808.000
Bye,
bearophile