Basic Arithmetic
See
src/vm_core/utility/arithmetic.ts
Since the JavaScript only have number
type, which is an abstraction of float
/int
. We use functions in arithmetic.ts
to perform basic arithmetic operations like +
, -
, *
or /
.
These functions will try its best to mimic the overflow behavior of C program.
What is Issue_Handler
in c_mul
's header'?
These functions are not perfect. A specific example is shown below:
This is due to the precision lost problem of float
. When such precision lost is detected, C0VM.ts will NOT interrupt the execution. However, we do want the user to realize such imprecise calculation. Therefore, we will use IssueHandler
to emit a warning to user. The IssueHandler
is an object that follows the MessageEmitter
interface.
By passing in different implementation of MessageEmitter
, we may have one of the following behaviors: 1) log a warning in the console, 2) popup a warning in the GUI, etc.
Last updated