Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| math:start [2025/09/22 22:22] – [Functions] rajit | math:start [2025/09/23 11:02] (current) – [Fixed point data type] rajit | ||
|---|---|---|---|
| Line 18: | Line 18: | ||
| This function takes an integer '' | This function takes an integer '' | ||
| - | ===== Datatypes | + | ===== Fixed point data type ===== |
| The standard math library has a fixed point data type. | The standard math library has a fixed point data type. | ||
| Line 26: | Line 26: | ||
| </ | </ | ||
| - | This datatype uses the '' | + | This datatype uses the standard |
| + | |||
| + | The following code fragment initializes the fixed point value '' | ||
| + | <code act> | ||
| + | math:: | ||
| + | ... | ||
| + | chp { | ||
| + | x.set(x.const(5.25)); | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | Other ways to initialize '' | ||
| + | <code act> | ||
| + | ... | ||
| + | chp { | ||
| + | x.x := 0x0f; | ||
| + | ... | ||
| + | | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | For debugging purposes, two macros are also provided for displaying the value of a fixed point number. The '' | ||
| + | <code act> | ||
| + | chp { | ||
| + | ... | ||
| + | | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| Line 92: | Line 121: | ||
| This can be used to convert a real constant value into its fixed point representation. Note that since '' | This can be used to convert a real constant value into its fixed point representation. Note that since '' | ||
| + | These functions are used by the fixed point data type. | ||