Q
Quinn Kirsch
Hi all,
the following c# example baffles me. my understanding of
the managed code of visual .net is that all casts like
this would be safe, but this example seems to contradict
this notion. if you look at the debugger info, the double
dou is half filled w/ garbage bits, instead of those bits
being zeroed out appropriately.
using System;
namespace decimaltodouble {
class Class1 {
[STAThread]
static void Main(string[] args) {
decimal dec = 0.4695M;
float fl = (float) dec;
double dou = (double) fl;
if (dou != 0.4695)
Console.Write("bad cast, garbage bits");
Console.Read();
}
}
}
the following c# example baffles me. my understanding of
the managed code of visual .net is that all casts like
this would be safe, but this example seems to contradict
this notion. if you look at the debugger info, the double
dou is half filled w/ garbage bits, instead of those bits
being zeroed out appropriately.
using System;
namespace decimaltodouble {
class Class1 {
[STAThread]
static void Main(string[] args) {
decimal dec = 0.4695M;
float fl = (float) dec;
double dou = (double) fl;
if (dou != 0.4695)
Console.Write("bad cast, garbage bits");
Console.Read();
}
}
}