code wiki / (root) / nx_cpp_calc.nx

nx_cpp_calc.nx source

↩ module page · 55 lines · 3059 B

1// nx_cpp_calc.nx -- Calculates honest cost-per-page using real coverage measurements and ISO-standardized yields. 2const K_MAGIC_50000: i64 = 50000 3// nx_cpp_calc.nx -- cost-per-page (CPP) calculator: turn cartridge price + ISO yield + OUR measured real 4// coverage into honest $/page, and the genuine-vs-aftermarket savings the cartridge industry obscured for 5// years (the researcher's sources: vendors hid yields until ISO/IEC 19752/19798 standardized them; refills/ 6// remanufactured = 30% of the market precisely because OEM CPP is high). Our edge: we measure REAL coverage, 7// so we give the true CPP for a user's ACTUAL documents, not just the vendor's 5%-ISO marketing number. 8// 9// PURE integer arithmetic (money in CENTS, CPP in MILLI-CENTS/page = 1/1000 cent, so 4166 = 4.166 cents/page); 10// no float, no syscalls -> never-brick #26. Grounded: ISO/IEC 19752 standard page = 5% coverage = 50000 ppm. 11// genealogy_id: project-printer-management-ipp-sclass-2026-06-20 ; license_tier: ORIGINAL 12 13// CPP at the ISO 5% standard yield. price in cents, yield in ISO pages. Returns milli-cents/page, -1 if bad. 14func nx_cpp_iso(price_cents: i64, yield_pages: i64) -> i64 { 15 if yield_pages <= 0 { return 0 - 1 } 16 if price_cents < 0 { return 0 - 1 } 17 return (price_cents * 1000) / yield_pages 18} 19 20// REAL pages a cartridge yields at OUR measured coverage (ppm). capacity = yield*50000 ppm (the 5% ISO page). 21func nx_cpp_real_pages(yield_pages: i64, coverage_ppm: i64) -> i64 { 22 if yield_pages <= 0 { return 0 - 1 } 23 if coverage_ppm <= 0 { return 0 - 1 } 24 return (yield_pages * K_MAGIC_50000) / coverage_ppm 25} 26 27// REAL CPP at OUR measured coverage. real_CPP = price * coverage_ppm / (yield * 50) milli-cents/page 28// (derivation: price / [(yield*50000)/coverage] * 1000). At 5% (50000 ppm) it equals the ISO CPP; heavier 29// pages cost proportionally more -- the HONEST per-document number the vendor's 5% marketing hides. 30func nx_cpp_real(price_cents: i64, yield_pages: i64, coverage_ppm: i64) -> i64 { 31 if yield_pages <= 0 { return 0 - 1 } 32 if coverage_ppm < 0 { return 0 - 1 } 33 if price_cents < 0 { return 0 - 1 } 34 let denom: i64 = yield_pages * 50 35 if denom <= 0 { return 0 - 1 } 36 return (price_cents * coverage_ppm) / denom 37} 38 39// savings (milli-cents/page) of aftermarket vs genuine at ISO yield. -1 if either input is bad. 40func nx_cpp_savings(genuine_cents: i64, genuine_yield: i64, after_cents: i64, after_yield: i64) -> i64 { 41 let g: i64 = nx_cpp_iso(genuine_cents, genuine_yield) 42 let a: i64 = nx_cpp_iso(after_cents, after_yield) 43 if g < 0 { return 0 - 1 } 44 if a < 0 { return 0 - 1 } 45 return g - a 46} 47 48// savings as a percent (0..100) of the genuine CPP. -1 if genuine CPP is unknown/zero. 49func nx_cpp_savings_pct(genuine_cents: i64, genuine_yield: i64, after_cents: i64, after_yield: i64) -> i64 { 50 let g: i64 = nx_cpp_iso(genuine_cents, genuine_yield) 51 let a: i64 = nx_cpp_iso(after_cents, after_yield) 52 if g <= 0 { return 0 - 1 } 53 if a < 0 { return 0 - 1 } 54 return ((g - a) * 100) / g 55}