I'm working on the decimal number package for D. A decimal is a struct with precision, max exponent and rounding mode parameters: "Decimal!(PRECISION, MAX_EXPO, ROUNDING)". I was trying to overload the opCast operator for this struct and I found that it does not seem necessary. I can cast decimals with different precisions, etc., back and forth without overloading opCast.

This code works:

alias dec9  = Decimal!(9,99);
alias dec10 = Decimal!(10,99);

dec9 bingo = dec9("123.45");
dec10 little = cast(dec10(bingo));

assert(little == dec10("123.45"));

Is this expected behavior?

Paul

Reply via email to