{"name":"scale","intro":"One quantity changes and everything tied to it has to change with it: a recipe for 4 becomes a recipe for 7, a price per kilogram becomes a price per 250 g, three workers become twelve. `scale` computes the factor once and applies it to every entity, returning each result as a decimal, an exact fraction, a mixed number, and its floor/ceiling — so “1 ¾ cups” and “round up to 2 eggs” are both already there.","when_to_use":["Recipe and batch scaling, where fractions matter more than decimals.","Unit-price conversion: `from_unit`/`to_unit` fold the unit change into the factor.","Inverse proportion — more workers, fewer days — with `mode: inverse`.","Any “hold the ratios constant” calculation across several line items at once."],"network":false,"related":"[`convert`](/docs/tools/convert) when only the unit changes · [`numbers`](/docs/tools/numbers) `allocate` when a total must be split so the parts sum exactly · [`math`](/docs/tools/math) for anything that is not a proportion.","docs_url":"/docs/tools/scale","modes":[{"name":"linear","purpose":"Direct proportion: double the input, double every entity.","description":"The default. The factor is `to_qty / from_qty`; every entity is multiplied by it. Supply `from_unit` and `to_unit` and the unit change is folded into the factor (1 kg → 250 g gives a factor of ¼). Supply `factor` directly to skip the ratio entirely. Each entity comes back with `original`, `scaled` and `per_unit`, each carrying a decimal, an exact fraction, a mixed number, a floor and a ceiling; set `integer: true` on an entity that cannot be fractional and it is rounded up with a warning.","parameters":[{"name":"from_qty","type":"number \\| string","required":true,"doc":"The quantity you have. Not required if `factor` is given.","default":null},{"name":"to_qty","type":"number \\| string","required":false,"doc":"The quantity you want.","default":"1, if `to_unit` is given"},{"name":"from_unit","type":"string","required":false,"doc":"Unit of `from_qty`.","default":null},{"name":"to_unit","type":"string","required":false,"doc":"Unit of `to_qty`; the conversion is folded into the factor.","default":null},{"name":"factor","type":"number \\| string","required":false,"doc":"Use this factor instead of a ratio.","default":null},{"name":"entities","type":"object[] \\| object","required":false,"doc":"Things to scale: `{name, qty, unit?, integer?}`, or a `{name: qty}` map.","default":null},{"name":"precision","type":"integer","required":false,"doc":"Decimal places in the `value` fields.","default":"`6`"},{"name":"assume","type":"string","required":false,"doc":"Pass `common` to resolve ambiguous units to their usual reading.","default":null}],"examples":[{"mode":"linear","from_qty":4,"to_qty":7,"entities":[{"name":"flour","qty":2,"unit":"cups"},{"name":"butter","qty":150,"unit":"g"},{"name":"eggs","qty":2,"integer":true}]},{"mode":"linear","from_qty":1,"from_unit":"kg","to_qty":250,"to_unit":"g","entities":[{"name":"price","qty":480}]},{"mode":"linear","factor":1.15,"entities":{"salary":62000,"bonus":8000}},{"mode":"linear","from_qty":0,"to_qty":7,"entities":[{"name":"flour","qty":2}]},{"mode":"linear","from_qty":4,"to_qty":7,"entities":[{"name":"flour"}]},{"mode":"linear","from_qty":1,"from_unit":"kg","to_qty":1,"to_unit":"liter","entities":[{"name":"price","qty":480}]},{"mode":"linear","from_qty":1,"from_unit":"oz","to_qty":100,"to_unit":"g","entities":[{"name":"price","qty":480}]},{"mode":"quadratic","from_qty":4,"to_qty":7,"entities":[{"name":"flour","qty":2}]}]},{"name":"inverse","purpose":"Inverse proportion: double the input, halve every entity.","description":"For quantities that move the other way. The factor becomes `from_qty / to_qty`, so tripling the workers divides the days by three. Everything else — entities, exact fractions, `integer` rounding — behaves as in `linear`. `percent_change` is `null` here, because a percentage change of an inverse relationship invites misreading.","parameters":[{"name":"from_qty","type":"number \\| string","required":true,"doc":"The quantity you have.","default":null},{"name":"to_qty","type":"number \\| string","required":true,"doc":"The quantity you want.","default":null},{"name":"entities","type":"object[] \\| object","required":false,"doc":"Things that move inversely: `{name, qty, unit?, integer?}`.","default":null},{"name":"from_unit","type":"string","required":false,"doc":"Unit of `from_qty`.","default":null},{"name":"to_unit","type":"string","required":false,"doc":"Unit of `to_qty`.","default":null},{"name":"precision","type":"integer","required":false,"doc":"Decimal places in the `value` fields.","default":"`6`"}],"examples":[{"mode":"inverse","from_qty":3,"to_qty":12,"entities":[{"name":"days","qty":5}]},{"mode":"inverse","from_qty":2,"to_qty":5,"entities":{"hours_per_batch":6,"operators_hours":18}},{"mode":"inverse","from_qty":3,"to_qty":0,"entities":[{"name":"days","qty":5}]},{"mode":"inverse","from_qty":"a few","to_qty":12,"entities":[{"name":"days","qty":5}]}]}]}