Reverse-Engineering Subscription Quotas from Floating-Point Usage: A Technical Method for Subscription Cost Optimization

    This article walks through a real-world case in which an unrounded floating-point number in a web API response exposed a platform's internal quota structure. It explains the underlying math (IEEE 754 doubles as rationals, rational reconstruction via continued fractions or Stern-Brocot search), shows how to normalize different resources into a common credit unit with model and input/output multipliers, and demonstrates how the short-window and long-period constraints together determine real usable capacity. It then gives a reusable decision process for picking the cheapest plan, plus the observability, alerting, and cost-attribution capabilities needed to avoid wasting quota.

    1. Background: An Unrounded Decimal Leaked the Pricing Model

    Before a release of an AI coding tool, a developer noticed an oddly precise value in the usage data returned by the web endpoint: 0.16327272727272726. Seventeen decimal places with a clearly repeating pattern is not something a business system would deliberately expose; it looks like an intermediate result from an internal calculation that was never rounded.

    Using rational reconstruction, the developer recovered the original fraction from that float, cross-checked it against several other samples, and reconstructed the real quota structure of the platform’s subscription plans. The technical value of the case is not the snooping itself but the general engineering lesson it illustrates: any system that carries business semantics in floating-point values can leak internal rules if it lacks rounding and data masking. For consumers, the same method can quantify whether the compute or quota they paid for is actually being used.

    Note that this kind of reverse-engineering is only suitable as a technical analysis technique; actual purchasing decisions should still rely on the vendor’s official published billing terms.

    2. The Math: Floating-Point Numbers Are Approximations of Rationals

    An IEEE 754 double-precision float is essentially a rational number of the form m × 2^-k, so every float string corresponds to an exact fraction — the denominator is just usually enormous (on the order of 2^52). Quantities like “quota share” or “multiplier” in a business system, however, typically have very small real denominators (tens to a few thousand). The problem therefore becomes:

    Among all rational numbers whose denominator does not exceed a given bound N, find the one closest to the observed value x.

    This is exactly rational reconstruction, and there are two standard solutions:

    1. Continued fraction expansion: take successive convergents, and once the denominator exceeds the bound, fall back to the previous convergent. The result is the “best rational approximation.”
    2. Stern-Brocot tree search: start from the interval [0/1, 1/0], repeatedly take the mediant, and move left or right depending on the size comparison until the denominator exceeds the bound.

    Both yield the same result, and the continued fraction version is more compact:

    1. # Illustrative code: best rational approximation with a bounded denominator
    2. function reconstruct(x, max_den):
    3. p_prev, q_prev = 0, 1 # previous convergent
    4. p, q = 1, 0 # current convergent
    5. y = x
    6. loop:
    7. a = floor(y) # nth term of the continued fraction
    8. p_prev, p = p, a*p + p_prev
    9. q_prev, q = q, a*q + q_prev
    10. if q > max_den: # out of bounds, fall back
    11. return p_prev / q_prev
    12. r = y - a
    13. if r < 1e-12: # exact hit
    14. return p / q
    15. y = 1 / r

    Running this on the value from the case with max_den = 10000 yields an exact fraction with a small denominator, and the tiny floating-point error is absorbed automatically. Two engineering points matter: max_den must be chosen based on the business magnitude (too large degenerates into the float itself, too small causes a mismatch), and multiple samples must resolve to the same fraction — otherwise the model assumption is wrong.

    3. Reconstructing the Quota Structure: A Common Unit and Multipliers

    To compare tiers, first convert all resources into a unified “credit” unit. The general approach:

    • Model multipliers: different tiers of models consume at different rates; a high-capability model typically costs 1.5–2x a mid-tier model and 4–6x a lightweight one.
    • Input/output multipliers: output consumption is generally much higher than input, commonly 4–5x.
    • Dual constraints: nearly every subscription has both a “short-window quota” (e.g., 5 hours) and a “long-period cap” (e.g., weekly). The intersection of the two is the real usable amount.

    Using sample data (for algorithm illustration only, not the parameters of any real product):

    Tier Price Window quota Period cap Cost per period per million
    Entry 20 550K 5M 2.50 / million
    Mid 100 3.3M 41.67M 2.40 / million
    High 200 11M 83.33M 2.40 / million

    The advertised “5x usage” is actually about 6x on the window dimension and about 8.33x on the period dimension — the multipliers on the two dimensions are not equal, which is exactly why many users feel they “bought a bigger tier but can’t use it up,” or conversely that the bigger tier is better value.

    4. How to Pick the Cheapest Option: A Reusable Decision Process

    1. Collect real usage: measure input tokens, output tokens, and call counts per model separately, then convert to credits using the multipliers.
    2. Identify the binding constraint: plot the daily consumption series and check whether peak 5-hour consumption hits the window quota and whether the weekly total hits the period cap. If the window is the bottleneck, you need a higher tier; if the period is the bottleneck, the tier is already sufficient and the problem is waste.
    3. Compute effective unit cost: effective cost = price / min(period cap, real period demand). Idle quota creates no value, and a nominal discount is not an effective discount.
    4. Verify multiplier consistency: cross-check multiple data sets with rational reconstruction to confirm the quota structure has not changed across versions.
    5. Keep downgrade flexibility: prefer plans that can be adjusted monthly and support seat reclamation, avoiding long-term lock-in.

    5. Engineering Support: Monitoring, Alerting, and Cost Attribution

    Whichever tier you choose, a lack of observability leads to wasted quota. Three general capabilities are recommended:

    • Usage instrumentation and logging: emit metrics per user, project, and model, retaining raw input and output volumes.
    • Monitoring and alerting: set tiered thresholds (e.g., 70%/90%) on window consumption rate and period accumulation ratio, triggering downgrade or queueing policies in advance.
    • Cost attribution and quota governance: perform unified metering and rate limiting at the gateway layer, use “credits” as the internal settlement unit, and reduce multiplier consumption with cache reuse, prompt trimming, and routing to lighter models first.

    In a cloud deployment, these capabilities can be carried by general product categories such as logging services, monitoring and alerting, message queues, and container platforms, with no dependency on any proprietary interface.

    6. Conclusion

    An unrounded float exposes internal metering rules, and it also reminds us that subscription cost optimization is fundamentally a data problem. First use rational reconstruction to turn fuzzy data into exact quotas, then use the dual-constraint model to compute effective unit cost, and finally use monitoring and attribution to push waste as low as possible. This process applies to any platform measured in credits, compute, or tokens, and it is the most reliable technical path to controlling long-term spend.