File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed
developer-guides/documentation/vala-for-csharp-devs
tutorials/programming-language/main Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 99- no ` decimal `
1010- C# ` char ` is UCS-2, not Vala's ` char ` , but similar to Vala\' s UCS-4
1111 ` unichar `
12+
13+ ## Numeric Suffixes
14+
15+ Both Vala and C# support numeric suffixes and are case-insensitive. The following suffixes are supported in Vala:
16+
17+ ** Integer Suffixes**
18+
19+ | Suffix | Type |
20+ | --------| --------|
21+ | | int |
22+ | u | uint |
23+ | l | long |
24+ | ll | int64 |
25+ | ul | ulong |
26+ | ull | uint64 |
27+
28+ ** Floating-point Suffixes**
29+
30+ | Suffix | Type |
31+ | --------| --------|
32+ | | double |
33+ | f | float |
34+ | d | double |
35+
36+ Differences between Vala and C#:
37+ - Vala does not support the ` m ` suffix, which represents the decimal type
38+ - Vala does not support rearranging the order of the suffix ` ul ` to be ` lu `
39+ - Vala does not infer the type of ` l ` to be either ` long ` or ` ulong `
40+ - Vala does not infer the type of ` u ` to be either ` uint ` or ` ulong `
41+ - Vala does not infer the type of suffixless numbers.
42+ - C# does not have the ` ull ` or ` ll ` suffixes.
Original file line number Diff line number Diff line change 1212- [ 2.4.5. Static Type Casting] ( 02-00-basics/02-04-data-types#_2-4-5-static-type-casting )
1313- [ 2.4.6. Type Inference] ( 02-00-basics/02-04-data-types#_2-4-6-type-inference )
1414- [ 2.4.7. Defining new Type from other] ( 02-00-basics/02-04-data-types#_2-4-7-defining-new-type-from-other )
15+ - [ 2.4.8. Numeric Type Suffixes] ( 02-00-basics/02-04-data-types#_2-4-8-numeric-type-suffixes )
1516
1617#### [ 2.5. Operators] ( 02-00-basics/02-05-operators )
1718#### [ 2.6. Control Structures] ( 02-00-basics/02-06-control-structures )
Original file line number Diff line number Diff line change @@ -362,3 +362,45 @@ public class ValueList : GLib.List<GLib.Value> {
362362 public static GLib.Type get_type ();
363363}
364364```
365+
366+ ## 2.4.8. Numeric Type Suffixes
367+
368+ Like many other languages, Vala supports numeric type suffixes.
369+
370+ The following sections list the supported suffixes, which are case-insensitive:
371+
372+ ### 2.4.8.1. Integer Suffixes
373+
374+ | Suffix | Type |
375+ | --------| --------|
376+ | | int |
377+ | u | uint |
378+ | l | long |
379+ | ll | int64 |
380+ | ul | ulong |
381+ | ull | uint64 |
382+
383+ Here are some examples:
384+ ``` vala
385+ var a = 123; // int
386+ var b = 123u; // uint
387+ var c = 123l; // long
388+ var d = 123ll; // ulong
389+ var e = 123ul; // ulong
390+ var f = 123ull; // uint64
391+ ```
392+
393+ ### 2.4.8.2. Floating-point Suffixes
394+
395+ | Suffix | Type |
396+ | --------| --------|
397+ | | double |
398+ | f | float |
399+ | d | double |
400+
401+ Here are some examples:
402+ ``` vala
403+ var a = 123.0; // double
404+ var b = 123.0f; // float
405+ var c = 123.0d; // double
406+ ```
You can’t perform that action at this time.
0 commit comments