HLSL statements are constructed using the following rules for grammar.
- Floating point numbers
- Integer numbers
- Related topics
The following characters are recognized as white space.
|C style comments (/* */)|
|C++ style comments (//)|
Floating point numbers are represented in HLSL as follows:
- fractional-constant exponent-part(opt) floating-suffix(opt)
digit-sequence exponent-part floating-suffix(opt)
- fractional-constant :
digit-sequence(opt) . digit-sequence
- exponent-part :
e sign(opt) digit-sequence
E sign(opt) digit-sequence
- sign : one of
- digit-sequence :
- floating-suffix : one of
h H f F l L
Use the “L” suffix to specify a full 64-bit precision floating-point literal. A 32-bit float literal is the default.
For example, the compiler recognizes the following literal value as a 32-bit precision floating-point literal and ignores the lower bits:
double x = -0.6473313946860445;
The compiler recognizes the following literal value as a 64-bit precision floating-point literal:
double x = -0.6473313946860445L;
Integer numbers are represented in HLSL as follows:
- integer-constant integer-suffix(opt)
- integer-constant: one of
# (decimal number)
0# (octal number)
0x# (hex number)
- integer-suffix can be any one of these:
u U l L
Characters are represented in HLSL as follows:
|'\a' '\b' '\f' '\b' '\r' '\t' '\v'||(escapes)|
|'\###'||(octal escape, each # is an octal digit)|
|'\x#'||(hex escape, # is hex number, any number of digits)|
|'\c'||(c is other character, including backslash and quotation marks)|
Escapes are not supported in preprocessor expressions.
Strings are represented in HLSL as follows:
"s" (s is any string with escapes).
Identifiers are represented in HLSL as follows:
##, #@, ++, --, &, &, &, ||, ==, ::, <<, <<=, >>, >>=, ..., <=, >=, !=, *=, /=, +=, -=, %=, &=, |=, ^=, ->
Also any other single character that did not match another rule.