[Vala] Using float literals in Vala source
- From: Kerrick Staley <mail kerrickstaley com>
- To: vala-list gnome org
- Subject: [Vala] Using float literals in Vala source
- Date: Sat, 26 May 2012 00:13:09 -0500
When a floating-point literal (e.g. "3.0") appears in Vala source code, it
is treated as a double. Since Vala will not automatically convert doubles
to floats, you can't write something such as:
var constraint = new Clutter.AlignConstraint(stage, AlignAxis.X_AXIS, 0.5);
This code gives the error:
Cannot convert from `double' to `float'
To fix it, the 0.5 must be changed to 0.5f. I think it would be more
convenient and intuitive to automatically cast the double to a float in
this context. Automatic casting would be consistent with C and C++ but
inconsistent with C# and Java.
- Kerrick
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]