Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
sqrt.c File Reference

Implements the OP_SQRT opcode using C99 math.h sqrt(). More...

#include <math.h>
Include dependency graph for sqrt.c:

Go to the source code of this file.

Functions

 if (v.type==VAL_INT||v.type==VAL_FLOAT)
 exit (1)

Variables

case OP_SQRT
 else
 break

Detailed Description

Implements the OP_SQRT opcode using C99 math.h sqrt().

Behavior:

  • Pops one numeric operand (int or float).
  • If x < 0, pushes NaN; else pushes sqrt(x).
  • Returns VAL_INT when the result fits exactly in int64, otherwise VAL_FLOAT.

Stack effect:

  • Pop: x
  • Push: sqrt(x) | NaN

Definition in file sqrt.c.

Function Documentation

◆ exit()

exit(1)

◆ if()

if(v.type = VAL_INT || v.type == VAL_FLOAT)

Definition at line 28 of file sqrt.c.

Here is the call graph for this function:

Variable Documentation

◆ break

break

Definition at line 51 of file sqrt.c.

◆ else

else
Initial value:
{
fprintf(stderr, "Runtime type error: SQRT expects number, got %s\n", value_type_name(v.type))
Value v
Definition cast.c:22
#define fprintf
Definition vm.c:200

Definition at line 47 of file sqrt.c.

◆ OP_SQRT

case OP_SQRT

Definition at line 26 of file sqrt.c.