Home /Modules/math/SLMathNorms.sleela

SLMathNorms.sleela

lib/math/SLMathNorms.sleela · 102 line(s) · sleela

<< lib/math/SLMathNorms.sleela
   SLeeLa Standard Library Definition.
   Definition: SLMathNorms carries the math precision norms for SLeeLa -- how
   many digits are carried for irrational constants, repeating decimals, and
   Finance Verbs. The authoritative, user-editable values live in
   lib/math/MATH.PRECISION.NORMS.md and lib/math/math-precision-norms.json;
   these compiled constants are the baseline a build starts from when no config
   file is read. >>
#sleela 2.5
material;
< SLeeLa mathematics precision-norm contract. >
class SLMathNorms {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 7902;
  String metaAuthor = "Max Rupplin";
  String metaDate = "2026-11-06";
  String metaCopyright = "MEARVK LLC";
  String metaTrademark = "none";
  String metaCorporation = "MEARVK LLC";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-11-06";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 8;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }

  << ---- The precision norms (defaults; override via math-precision-norms.json)
     DEFAULT_IRRATIONAL_CARRY  digits carried for irrational constants.
     DEFAULT_REPEATING_CARRY   digits carried for repeating decimals.
     DEFAULT_FINANCE_CARRY     minimum digits for Finance Verbs (floor 1023). >>
  static final int DEFAULT_IRRATIONAL_CARRY = 2048;
  static final int DEFAULT_REPEATING_CARRY = 58;
  static final int DEFAULT_FINANCE_CARRY = 1023;

  < The hard floor below which a Finance Verb must not be configured. >
  static final int FINANCE_CARRY_FLOOR = 1023;

  < Live values, seeded from the defaults, overridable at runtime via setters. >
  int irrationalCarry;
  int repeatingCarry;
  int financeCarry;

  < Start from the compiled defaults. >
  void initDefaults() {
    irrationalCarry = DEFAULT_IRRATIONAL_CARRY;
    repeatingCarry = DEFAULT_REPEATING_CARRY;
    financeCarry = DEFAULT_FINANCE_CARRY;
  }

  int getIrrationalCarry() { return irrationalCarry; }
  int getRepeatingCarry() { return repeatingCarry; }
  int getFinanceCarry() { return financeCarry; }

  void setIrrationalCarry(int v) { if (v >= 1) { irrationalCarry = v; } }
  void setRepeatingCarry(int v) { if (v >= 1) { repeatingCarry = v; } }

  << Finance is an irregular concept: its carry must never be less than 1023.
     A request below the floor is rejected and the value is pinned to the floor;
     accepts returns false so a caller can see the request was clamped. >>
  boolean setFinanceCarry(int v) {
    if (v < FINANCE_CARRY_FLOOR) { financeCarry = FINANCE_CARRY_FLOOR; return false; }
    financeCarry = v;
    return true;
  }

  < Is the current finance carry valid (at or above the floor)? >
  boolean financeCarryValid() { return financeCarry >= FINANCE_CARRY_FLOOR; }

  < The hard floor for finance carry, reachable without instance-static access. >
  int financeFloor() { return FINANCE_CARRY_FLOOR; }

  boolean available() { return irrationalCarry > 0 && financeCarry >= FINANCE_CARRY_FLOOR; }
}