Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #932 (closed defect: fixed)

Opened 5 months ago

Last modified 3 months ago

to!(double)(float) fails to compile

Reported by: mariusmuja Assigned to: DRK
Priority: normal Milestone: 0.99.7
Component: Core Functionality Version: 0.99.4 Frank
Keywords: Cc:

Description

The following code:

import tango.util.Convert;
import tango.io.Stdout;
void main()
{
   float a = 1.0f;
   Stdout.formatln("Value is: ",to!(double)(a));
}

fails to compile with the following assertion:

/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../include/d/4.1.2/tango/util/Convert.d:468: static assert "Unsupported conversion: cannot convert to double from float."

Change History

02/22/08 23:48:29 changed by kris

  • owner changed from sean to DRK.

03/04/08 04:24:19 changed by Jim Panic

  • milestone changed from 0.99.5 to 0.99.6.

04/27/08 05:18:20 changed by larsivi

  • milestone changed from 0.99.6 to 0.99.7.

05/09/08 08:39:27 changed by mandel

In tango/util/Convert.d, in function
"D toReal(D,S)(S value)":

static if( isIntegerType!(S))
{
     return cast(D) value;
}

should be changed to this:

static if( isIntegerType!(S) || isRealType!(S))
{
     return cast(D) value;
}

Then, toFloat will be able to convert real types to other real types.

05/09/08 14:48:38 changed by larsivi

  • status changed from new to closed.
  • resolution set to fixed.

(In [3493]) toReal can now convert from float to float, thanks mandel, closes #932