convertValue

template convertValue(DataType DT)
convertValue
pure
(
T
)
(
T val
)

Examples

1 static assert( convertValue!(DataType.NORM_FIXED)(1.0)  == int.max );
2 static assert( convertValue!(DataType.NORM_FIXED)(0.5)  == int.max/2 );
3 static assert( convertValue!(DataType.NORM_FIXED)(0.0)  == 0 );
4 static assert( convertValue!(DataType.NORM_FIXED)(-0.5) == int.min/2 );
5 static assert( convertValue!(DataType.NORM_FIXED)(-1.0) == int.min );
6 static assert( is( typeof( convertValue!(DataType.NORM_FIXED)(1.0) ) == int ) );

Meta