LLvlN-FLOAT
LLvlN-FLOAT is a variant of LLvlN that extends the base language with floating-point "spice" registers and arithmetic operations. Created in 2025, this variant maintains all the culinary-themed absurdity of the original while adding decimal precision cooking to the mix.
This variant provides a concrete implementation of floating-point operations within the food-themed programming paradigm.
Overview
LLvlN-FLOAT enhances the original LLvlN with:
- 4 additional floating-point "spice" registers (SALT, PEPPER, GARLIC, GINGER)
- Floating-point arithmetic operations with culinary flair
- Type mixing between integer "ingredients" and floating-point "spices"
- Precision control through "seasoning" instructions
- IEEE 754 compliance for serious computational cooking
The language maintains backward compatibility with standard LLvlN programs while providing the precision needed for more sophisticated culinary calculations.
Language Specification
Float Registers
In addition to the 8 integer registers from LLvlN (SOUP, CAKE, MEAT, FISH, RICE, BEAN, NUTS, MILK), LLvlN-FLOAT introduces 4 floating-point "spice" registers:
- SALT - Primary seasoning register (general-purpose float)
- PEPPER - Secondary seasoning register (often used for ratios)
- GARLIC - Aromatic computations (trigonometric operations)
- GINGER - Zesty calculations (exponential and logarithmic operations)
All spice registers are initialized to 0.0 at program start and store double-precision floating-point numbers (IEEE 754).
Float Instructions
Data Movement
- SEASON <spice_reg> <value> - Sets a spice register to a literal float value
- BLEND <dest_spice> <source_spice> - Copies value from source spice register to destination spice register
- INFUSE <dest_spice> <source_ingredient> - Converts integer register to float and stores in spice register
- EXTRACT <dest_ingredient> <source_spice> - Converts float register to integer (truncated) and stores in ingredient register
Floating-Point Arithmetic
All float arithmetic operations work on "spices":
- FADD <dest_spice> <source_spice> - Adds source spice to destination spice
- FSUB <dest_spice> <source_spice> - Subtracts source spice from destination spice
- FMUL <dest_spice> <source_spice> - Multiplies destination spice by source spice
- FDIV <dest_spice> <source_spice> - Divides destination spice by source spice
- FMOD <dest_spice> <source_spice> - Destination spice becomes destination modulo source (floating-point remainder)
- FPOW <dest_spice> <source_spice> - Raises destination spice to the power of source spice
Mathematical Functions
- FSIN <spice_reg> - Computes sine of spice register (in radians)
- FCOS <spice_reg> - Computes cosine of spice register (in radians)
- FTAN <spice_reg> - Computes tangent of spice register (in radians)
- FLOG <spice_reg> - Computes natural logarithm of spice register
- FEXP <spice_reg> - Computes e raised to the power of spice register
- FSQRT <spice_reg> - Computes square root of spice register
- FABS <spice_reg> - Computes absolute value of spice register
- FFLOOR <spice_reg> - Rounds spice register down to nearest integer (result stays float)
- FCEIL <spice_reg> - Rounds spice register up to nearest integer (result stays float)
- FROUND <spice_reg> - Rounds spice register to nearest integer (result stays float)
Type System
LLvlN-FLOAT maintains strict type separation between "ingredients" (integers) and "spices" (floats):
- Integer arithmetic operations (ADD, SUB, MUL, DIV, MOD) only work with ingredient registers
- Float arithmetic operations (FADD, FSUB, FMUL, FDIV, FMOD, FPOW) only work with spice registers
- Explicit conversion is required via INFUSE (int→float) and EXTRACT (float→int)
- Stack operations work with both types but maintain type information
Mixed Operations
- TASTE <spice_reg> FLOAT - Reads a floating-point number from input into spice register
- SERVE <spice_reg> FLOAT - Outputs the value in spice register as a floating-point number
- SERVE <spice_reg> FIXED <precision> - Outputs spice register with fixed decimal places
- FCMP <spice1> <spice2> - Compares two spice registers, sets BEAN register to 1, 0, or -1 (like integer CMP)
Enhanced Stack Operations
The stack in LLvlN-FLOAT can hold both integers and floats, maintaining type information:
- BAKE <register> [FLOAT] - Pushes register value onto stack (FLOAT keyword for spice registers)
- CHOP <register> [FLOAT] - Pops value from stack into register (FLOAT keyword for spice registers)
- Stack operations (BOIL, DICE, FLIP, STIR) preserve type information
Precision and Rounding
- All floating-point operations follow IEEE 754 double-precision standard
- Division by zero in floating-point operations produces ±infinity or NaN as appropriate
- Mathematical functions handle edge cases according to IEEE 754 (e.g., log of negative numbers produces NaN)
- The EXTRACT instruction truncates toward zero (not rounds)
- Comparison operations handle NaN according to IEEE 754 (NaN is not equal to anything, including itself)
Error Handling
Additional error conditions in LLvlN-FLOAT:
- Mathematical domain errors (e.g., sqrt of negative, log of non-positive)
- Overflow/underflow in floating-point operations
- Invalid conversions between types
- Stack type mismatches
Examples
Pi Calculation
RECIPE # Calculate pi using Leibniz formula (first 1000 terms) SEASON SALT 0.0 # Sum accumulator SEASON PEPPER 1.0 # Current term denominator SEASON GARLIC 1.0 # Sign (+1 or -1) SET SOUP 1000 # Number of terms PI_LOOP: BLAND SOUP PI_END # If counter is 0, done # Calculate current term: sign * (1/denominator) SEASON GINGER 1.0 FDIV GINGER PEPPER # 1/denominator FMUL GINGER GARLIC # Apply sign FADD SALT GINGER # Add to sum # Update for next iteration SEASON GINGER 2.0 FADD PEPPER GINGER # denominator += 2 SEASON GINGER -1.0 FMUL GARLIC GINGER # Flip sign SET MEAT 1 SUB SOUP MEAT # Decrement counter SALT PI_LOOP PI_END: SEASON GINGER 4.0 FMUL SALT GINGER # Multiply by 4 to get pi SERVE SALT FLOAT # Output pi approximation DONE
Floating-Point Calculator
RECIPE # Simple floating-point calculator TASTE SALT FLOAT # Read first number TASTE PEPPER FLOAT # Read second number # Addition BLEND GARLIC SALT FADD GARLIC PEPPER SERVE GARLIC FLOAT # Subtraction BLEND GARLIC SALT FSUB GARLIC PEPPER SERVE GARLIC FLOAT # Multiplication BLEND GARLIC SALT FMUL GARLIC PEPPER SERVE GARLIC FLOAT # Division BLEND GARLIC SALT FDIV GARLIC PEPPER SERVE GARLIC FLOAT DONE
Trigonometric Functions
RECIPE # Demonstrate trigonometric functions SEASON SALT 1.5708 # π/2 radians (90 degrees) BLEND PEPPER SALT FSIN PEPPER SERVE PEPPER FLOAT # Should output ~1.0 BLEND PEPPER SALT FCOS PEPPER SERVE PEPPER FLOAT # Should output ~0.0 BLEND PEPPER SALT FTAN PEPPER SERVE PEPPER FLOAT # Should output very large number DONE
Mixed Type Example
RECIPE # Convert temperature from Celsius to Fahrenheit SET SOUP 25 # 25°C INFUSE SALT SOUP # Convert to float SEASON PEPPER 9.0 SEASON GARLIC 5.0 FDIV PEPPER GARLIC # 9/5 = 1.8 FMUL SALT PEPPER # celsius * 1.8 SEASON PEPPER 32.0 FADD SALT PEPPER # Add 32 SERVE SALT FIXED 1 # Output with 1 decimal place DONE
Stack with Mixed Types
RECIPE # Demonstrate mixed-type stack operations SET SOUP 42 SEASON SALT 3.14159 BAKE SOUP # Push integer BAKE SALT FLOAT # Push float CHOP PEPPER FLOAT # Pop float (3.14159) CHOP CAKE # Pop integer (42) SERVE PEPPER FLOAT SERVE CAKE DONE
Implementation Notes
Memory Model
An LLvlN-FLOAT implementation should provide:
- 8 integer registers (32-bit or 64-bit signed integers)
- 4 floating-point registers (IEEE 754 double-precision)
- A typed stack supporting both integers and floats
- Standard input/output streams with float parsing support
Type Safety
- Runtime type checking for stack operations
- Compile-time validation of register types in operations
- Clear error messages for type mismatches
- Preservation of type information across stack operations
Floating-Point Considerations
- Implementations should handle IEEE 754 special values (infinity, NaN)
- Proper rounding modes should be supported
- Denormal numbers should be handled appropriately
- Mathematical function implementations should be reasonably accurate
Performance
Optimizations specific to LLvlN-FLOAT:
- Separate integer and float execution paths
- Type-aware constant folding
- Mathematical function lookup tables for common values
- Stack type prediction to minimize runtime type checking
Differences from LLvlN
- Adds 4 floating-point registers with culinary names
- Introduces floating-point arithmetic and mathematical functions
- Enhances stack operations to handle mixed types
- Extends I/O operations for floating-point values
- Maintains backward compatibility with integer-only programs
Differences from LLvlN++
Unlike LLvlN++ which focuses on procedural abstractions, LLvlN-FLOAT:
- Extends the type system rather than control structures
- Maintains the flat, assembly-like program structure
- Focuses on numerical computation rather than code organization
- Can be combined with LLvlN++ to create LLvlN-FLOAT++
Computational Class
LLvlN-FLOAT maintains the Turing completeness of the base LLvlN language while adding:
- Real number approximation capabilities
- Transcendental function computation
- Higher precision arithmetic for numerical algorithms
The floating-point extensions do not change the fundamental computational power but significantly expand the practical applications of the language.
Variants
- LLvlN-FLOAT++ - Combining floating-point operations with the function calls of LLvlN++
- LLvlN-DOUBLE-SPICE - Extended precision variant with 128-bit quadruple-precision floats
- LLvlN-COMPLEX - Adding complex number "flavor combinations"
See Also
- LLvlN - The base language
- LLvlN++ - Procedural variant
- Chef - Another cooking-themed esoteric language
- Floating point - General information about floating-point computation
External Resources
- IEEE 754-2019 - Floating-point standard reference