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

Implements the OP_SIN opcode using C99 math.h sin(). More...

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

Go to the source code of this file.

Functions

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

Variables

case OP_SIN
 else
 break

Detailed Description

Implements the OP_SIN opcode using C99 math.h sin().

VM opcode snippet included by vm.c. Provides sine function.

Behavior:

  • Pops one numeric operand (int or float) from the stack.
  • Computes sin(x) in double precision.
  • Always pushes a VAL_FLOAT result.

Stack effect:

  • Pop: x
  • Push: sin(x)

Types:

  • Accepts VAL_INT and VAL_FLOAT; others cause a runtime error.

Example:

  • Input [0] → Output [0.0]

Definition in file sin.c.

Function Documentation

◆ exit()

exit(1)

◆ if()

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

Definition at line 36 of file sin.c.

Here is the call graph for this function:

Variable Documentation

◆ break

break

Definition at line 45 of file sin.c.

◆ else

else
Initial value:
{
fprintf(stderr, "Runtime type error: SIN 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 41 of file sin.c.

◆ OP_SIN

case OP_SIN

Definition at line 34 of file sin.c.