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

Implements the OP_LOG opcode using C99 math.h log() (natural logarithm). More...

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

Go to the source code of this file.

Functions

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

Variables

case OP_LOG
 else
 break

Detailed Description

Implements the OP_LOG opcode using C99 math.h log() (natural logarithm).

Behavior:

  • Pops one numeric operand (int or float).
  • If x <= 0, pushes NaN to indicate domain error; otherwise pushes ln(x).
  • Result type is VAL_FLOAT.

Stack effect:

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

Types:

  • Accepts VAL_INT and VAL_FLOAT; errors on others.

Definition in file log.c.

Function Documentation

◆ exit()

exit(1)

◆ if()

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

Definition at line 31 of file log.c.

Here is the call graph for this function:

Variable Documentation

◆ break

break

Definition at line 45 of file log.c.

◆ else

else
Initial value:
{
fprintf(stderr, "Runtime type error: LOG 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 log.c.

◆ OP_LOG

case OP_LOG

Definition at line 29 of file log.c.