aboutsummaryrefslogtreecommitdiff
path: root/lib/apply-prefix.typ
blob: 51162ed9669910fea0dcf01666bf796f80ca8987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SAME Analog Modular Ecosystem
//
// / SPDX-FileCopyrightText: 2026 Denis Chevalier <perso@denischevalier.fr>
// / SPDX-License-Identifier: CC-BY-SA-4.0
// / SPDX-License-Identifier: CERN-OHL-S-2.0+
// / SPDX-License-Identifier: GPL-3.0-or-later
//
// The prose, explanatory text, rendered figures, tables, and mathematical
// content of this specification are licensed under CC BY-SA 4.0. If a later
// version of CC BY-SA is published, the author grants permission to distribute
// this work under that later version as well.
//
// Hardware designs contained herein (schematics, PCB layouts, mechanical
// drawings, and CAD models) are licensed under CERN-OHL-S-2.0+.
//
// All executable code, helper libraries (`lib/*`), metrology assertions, and
// embedded verification scripts throughout the source documents are licensed
// under the GNU General Public License v3.0 or later (GPL-3.0-or-later).

#let apply-prefix(value, prefix) = {
  if prefix == "tera" { return value * calc.pow(10, 12) }
  if prefix == "giga" { return value * calc.pow(10, 9) }
  if prefix == "mega" { return value * calc.pow(10, 6) }
  if prefix == "kilo" { return value * calc.pow(10, 3) }
  if prefix == "milli" { return value * calc.pow(10, -3) }
  if prefix == "micro" { return value * calc.pow(10, -6) }
  if prefix == "nano" { return value * calc.pow(10, -9) }
  if prefix == "pico" { return value * calc.pow(10, -12) }
  if prefix == "femto" { return value * calc.pow(10, -15) }
  return value
}