cmn 0.0.6

121 mathematical, physical, and cryptographic constants for Rust — no_std, WASM-ready, compile-time const, typed runtime lookup, 14 utility macros
Documentation
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
// Copyright © 2023-2026 Common (CMN) library. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};

/// A single named constant with its string-encoded value.
/// Requires the `std` feature.
#[cfg(feature = "std")]
#[non_exhaustive]
#[derive(
    Clone,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
    Serialize,
    Deserialize,
)]
pub struct Constant {
    /// The name of the constant.
    pub name: &'static str,

    /// The value of the constant.
    pub value: String,
}

/// Collection of 121 mathematical, physical, and cryptographic constants.
/// Requires the `std` feature.
#[cfg(feature = "std")]
#[derive(Clone, Serialize, Debug)]
pub struct Constants {
    /// A vector of constants.
    pub constants: Vec<Constant>,
}

#[cfg(feature = "std")]
impl Constants {
    /// Returns the value of the constant.
    ///
    /// # Example
    ///
    /// ```
    /// use cmn::constants::Constants;
    /// use cmn::constants::ConstantValue;
    ///
    /// let constants = Constants::new();
    /// let constant = constants.constant("EULER").unwrap();
    /// let value = constants.get_value(constant.name);
    ///
    /// if let Some(ConstantValue::Float(float_value)) = value {
    ///     assert!((float_value - 2.71828).abs() < 1e-5);
    /// }
    /// else {
    ///     panic!("Expected a float value");
    /// }
    ///
    /// ```
    pub fn get_value(&self, name: &str) -> Option<ConstantValue> {
        if let Some(constant) = self.constant(name) {
            match name {
                "HASH_COST" => {
                    constant.value.parse().map(ConstantValue::U32).ok()
                }
                "HASH_LENGTH" => constant
                    .value
                    .parse()
                    .map(ConstantValue::Usize)
                    .ok(),
                _ => {
                    if let Ok(float_value) =
                        constant.value.parse::<f64>()
                    {
                        Some(ConstantValue::Float(float_value))
                    } else if let Some(char_array) =
                        Self::get_char_array(name)
                    {
                        Some(ConstantValue::CharArray(char_array))
                    } else {
                        Some(ConstantValue::String(
                            constant.value.clone(),
                        ))
                    }
                }
            }
        } else {
            None
        }
    }

    fn get_char_array(name: &str) -> Option<&'static [char]> {
        match name {
            "SPECIAL_CHARS" => Some(SPECIAL_CHARS),
            _ => None,
        }
    }

    /// Looks up a single constant by name.
    ///
    /// Returns `Some(Constant)` if found, `None` otherwise.
    ///
    /// # Example
    ///
    /// ```
    /// use cmn::constants::Constants;
    ///
    /// let constants = Constants::new();
    /// let euler = constants.constant("EULER");
    /// assert_eq!(euler.unwrap().name, "EULER");
    ///
    /// assert!(constants.constant("NONEXISTENT").is_none());
    /// ```
    pub fn constant(&self, name: &str) -> Option<Constant> {
        self.constants
            .iter()
            .find(|constant| constant.name == name)
            .cloned()
    }

    /// Returns a slice of all 121 constants.
    ///
    /// # Example
    ///
    /// ```
    /// use cmn::constants::Constants;
    ///
    /// let constants = Constants::new();
    /// assert_eq!(constants.constants().len(), 121);
    /// ```
    pub fn constants(&self) -> &[Constant] {
        &self.constants
    }

    /// Create a new instance of the `Constants` structure.
    ///
    /// # Example
    ///
    /// ```
    /// use cmn::constants::Constants;
    ///
    /// let constants = Constants::new();
    /// assert_eq!(constants.constants().len(), 121);
    ///
    /// ```
    ///
    pub fn new() -> Self {
        let mut constants = Vec::with_capacity(121);
        constants.extend([
            Constant {
                name: "APERY",
                value: APERY.to_string(),
            },
            Constant {
                name: "AVOGADRO",
                value: AVOGADRO.to_string(),
            },
            Constant {
                name: "BOLTZMANN",
                value: BOLTZMANN.to_string(),
            },
            Constant {
                name: "CATALAN",
                value: CATALAN.to_string(),
            },
            Constant {
                name: "COULOMB",
                value: COULOMB.to_string(),
            },
            Constant {
                name: "EULER",
                value: EULER.to_string(),
            },
            Constant {
                name: "FARADAY",
                value: FARADAY.to_string(),
            },
            Constant {
                name: "GAMMA",
                value: GAMMA.to_string(),
            },
            Constant {
                name: "GAS_CONSTANT",
                value: GAS_CONSTANT.to_string(),
            },
            Constant {
                name: "GLAISHER_KINKELIN",
                value: GLAISHER_KINKELIN.to_string(),
            },
            Constant {
                name: "GRAVITATIONAL_CONSTANT",
                value: GRAVITATIONAL_CONSTANT.to_string(),
            },
            Constant {
                name: "HASH_ALGORITHM",
                value: HASH_ALGORITHM.to_string(),
            },
            Constant {
                name: "HASH_COST",
                value: HASH_COST.to_string(),
            },
            Constant {
                name: "HASH_LENGTH",
                value: HASH_LENGTH.to_string(),
            },
            Constant {
                name: "KHINCHIN",
                value: KHINCHIN.to_string(),
            },
            Constant {
                name: "PHI",
                value: PHI.to_string(),
            },
            Constant {
                name: "PI",
                value: PI.to_string(),
            },
            Constant {
                name: "PLANCK",
                value: PLANCK.to_string(),
            },
            Constant {
                name: "PLANCK_REDUCED",
                value: PLANCK_REDUCED.to_string(),
            },
            Constant {
                name: "SILVER_RATIO",
                value: SILVER_RATIO.to_string(),
            },
            Constant {
                name: "SPEED_OF_LIGHT",
                value: SPEED_OF_LIGHT.to_string(),
            },
            Constant {
                name: "SPECIAL_CHARS",
                value: SPECIAL_CHARS.iter().collect::<String>(),
            },
            Constant {
                name: "SQRT2",
                value: SQRT2.to_string(),
            },
            Constant {
                name: "SQRT3",
                value: SQRT3.to_string(),
            },
            Constant {
                name: "SQRT5",
                value: SQRT5.to_string(),
            },
            Constant {
                name: "TAU",
                value: TAU.to_string(),
            },
            Constant {
                name: "VACUUM_PERMEABILITY",
                value: VACUUM_PERMEABILITY.to_string(),
            },
            Constant {
                name: "VACUUM_PERMITTIVITY",
                value: VACUUM_PERMITTIVITY.to_string(),
            },
            // --- std::f64::consts math constants ---
            Constant {
                name: "LN_2",
                value: LN_2.to_string(),
            },
            Constant {
                name: "LN_10",
                value: LN_10.to_string(),
            },
            Constant {
                name: "LOG2_E",
                value: LOG2_E.to_string(),
            },
            Constant {
                name: "LOG10_E",
                value: LOG10_E.to_string(),
            },
            Constant {
                name: "FRAC_1_SQRT_2",
                value: FRAC_1_SQRT_2.to_string(),
            },
            Constant {
                name: "FRAC_1_PI",
                value: FRAC_1_PI.to_string(),
            },
            Constant {
                name: "FRAC_2_PI",
                value: FRAC_2_PI.to_string(),
            },
            Constant {
                name: "FRAC_2_SQRT_PI",
                value: FRAC_2_SQRT_PI.to_string(),
            },
            Constant {
                name: "FRAC_PI_2",
                value: FRAC_PI_2.to_string(),
            },
            Constant {
                name: "FRAC_PI_3",
                value: FRAC_PI_3.to_string(),
            },
            Constant {
                name: "FRAC_PI_4",
                value: FRAC_PI_4.to_string(),
            },
            Constant {
                name: "FRAC_PI_6",
                value: FRAC_PI_6.to_string(),
            },
            Constant {
                name: "FRAC_PI_8",
                value: FRAC_PI_8.to_string(),
            },
            // --- CODATA 2018 physical constants ---
            Constant {
                name: "ELEMENTARY_CHARGE",
                value: ELEMENTARY_CHARGE.to_string(),
            },
            Constant {
                name: "ELECTRON_MASS",
                value: ELECTRON_MASS.to_string(),
            },
            Constant {
                name: "PROTON_MASS",
                value: PROTON_MASS.to_string(),
            },
            Constant {
                name: "NEUTRON_MASS",
                value: NEUTRON_MASS.to_string(),
            },
            Constant {
                name: "STEFAN_BOLTZMANN",
                value: STEFAN_BOLTZMANN.to_string(),
            },
            Constant {
                name: "WIEN_DISPLACEMENT",
                value: WIEN_DISPLACEMENT.to_string(),
            },
            Constant {
                name: "STANDARD_GRAVITY",
                value: STANDARD_GRAVITY.to_string(),
            },
            Constant {
                name: "STANDARD_ATMOSPHERE",
                value: STANDARD_ATMOSPHERE.to_string(),
            },
            Constant {
                name: "ATOMIC_MASS_UNIT",
                value: ATOMIC_MASS_UNIT.to_string(),
            },
            Constant {
                name: "BOHR_RADIUS",
                value: BOHR_RADIUS.to_string(),
            },
            Constant {
                name: "FINE_STRUCTURE",
                value: FINE_STRUCTURE.to_string(),
            },
            Constant {
                name: "RYDBERG",
                value: RYDBERG.to_string(),
            },
            Constant {
                name: "MAGNETIC_FLUX_QUANTUM",
                value: MAGNETIC_FLUX_QUANTUM.to_string(),
            },
            Constant {
                name: "CONDUCTANCE_QUANTUM",
                value: CONDUCTANCE_QUANTUM.to_string(),
            },
            // --- Particle masses ---
            Constant {
                name: "MUON_MASS",
                value: MUON_MASS.to_string(),
            },
            Constant {
                name: "TAU_PARTICLE_MASS",
                value: TAU_PARTICLE_MASS.to_string(),
            },
            Constant {
                name: "DEUTERON_MASS",
                value: DEUTERON_MASS.to_string(),
            },
            Constant {
                name: "TRITON_MASS",
                value: TRITON_MASS.to_string(),
            },
            Constant {
                name: "HELION_MASS",
                value: HELION_MASS.to_string(),
            },
            Constant {
                name: "ALPHA_PARTICLE_MASS",
                value: ALPHA_PARTICLE_MASS.to_string(),
            },
            // --- Mass ratios ---
            Constant {
                name: "ELECTRON_PROTON_MASS_RATIO",
                value: ELECTRON_PROTON_MASS_RATIO.to_string(),
            },
            Constant {
                name: "PROTON_ELECTRON_MASS_RATIO",
                value: PROTON_ELECTRON_MASS_RATIO.to_string(),
            },
            Constant {
                name: "MUON_ELECTRON_MASS_RATIO",
                value: MUON_ELECTRON_MASS_RATIO.to_string(),
            },
            Constant {
                name: "NEUTRON_PROTON_MASS_RATIO",
                value: NEUTRON_PROTON_MASS_RATIO.to_string(),
            },
            Constant {
                name: "DEUTERON_PROTON_MASS_RATIO",
                value: DEUTERON_PROTON_MASS_RATIO.to_string(),
            },
            // --- Magnetic moments ---
            Constant {
                name: "BOHR_MAGNETON",
                value: BOHR_MAGNETON.to_string(),
            },
            Constant {
                name: "NUCLEAR_MAGNETON",
                value: NUCLEAR_MAGNETON.to_string(),
            },
            Constant {
                name: "ELECTRON_MAGNETIC_MOMENT",
                value: ELECTRON_MAGNETIC_MOMENT.to_string(),
            },
            Constant {
                name: "PROTON_MAGNETIC_MOMENT",
                value: PROTON_MAGNETIC_MOMENT.to_string(),
            },
            Constant {
                name: "NEUTRON_MAGNETIC_MOMENT",
                value: NEUTRON_MAGNETIC_MOMENT.to_string(),
            },
            Constant {
                name: "ELECTRON_G_FACTOR",
                value: ELECTRON_G_FACTOR.to_string(),
            },
            Constant {
                name: "PROTON_G_FACTOR",
                value: PROTON_G_FACTOR.to_string(),
            },
            // --- eV equivalents ---
            Constant {
                name: "ELECTRON_VOLT",
                value: ELECTRON_VOLT.to_string(),
            },
            Constant {
                name: "EV_TO_KG",
                value: EV_TO_KG.to_string(),
            },
            Constant {
                name: "EV_TO_AMU",
                value: EV_TO_AMU.to_string(),
            },
            Constant {
                name: "EV_TO_HZ",
                value: EV_TO_HZ.to_string(),
            },
            Constant {
                name: "EV_TO_KELVIN",
                value: EV_TO_KELVIN.to_string(),
            },
            Constant {
                name: "EV_TO_INVERSE_METER",
                value: EV_TO_INVERSE_METER.to_string(),
            },
            // --- Atomic & nuclear ---
            Constant {
                name: "CLASSICAL_ELECTRON_RADIUS",
                value: CLASSICAL_ELECTRON_RADIUS.to_string(),
            },
            Constant {
                name: "ELECTRON_COMPTON_WAVELENGTH",
                value: ELECTRON_COMPTON_WAVELENGTH.to_string(),
            },
            Constant {
                name: "PROTON_COMPTON_WAVELENGTH",
                value: PROTON_COMPTON_WAVELENGTH.to_string(),
            },
            Constant {
                name: "NEUTRON_COMPTON_WAVELENGTH",
                value: NEUTRON_COMPTON_WAVELENGTH.to_string(),
            },
            Constant {
                name: "THOMSON_CROSS_SECTION",
                value: THOMSON_CROSS_SECTION.to_string(),
            },
            Constant {
                name: "FIRST_RADIATION_CONSTANT",
                value: FIRST_RADIATION_CONSTANT.to_string(),
            },
            Constant {
                name: "SECOND_RADIATION_CONSTANT",
                value: SECOND_RADIATION_CONSTANT.to_string(),
            },
            Constant {
                name: "JOSEPHSON_CONSTANT",
                value: JOSEPHSON_CONSTANT.to_string(),
            },
            Constant {
                name: "VON_KLITZING_CONSTANT",
                value: VON_KLITZING_CONSTANT.to_string(),
            },
            Constant {
                name: "HARTREE_ENERGY",
                value: HARTREE_ENERGY.to_string(),
            },
            Constant {
                name: "HARTREE_ENERGY_EV",
                value: HARTREE_ENERGY_EV.to_string(),
            },
            // --- Planck units ---
            Constant {
                name: "PLANCK_MASS",
                value: PLANCK_MASS.to_string(),
            },
            Constant {
                name: "PLANCK_LENGTH",
                value: PLANCK_LENGTH.to_string(),
            },
            Constant {
                name: "PLANCK_TIME",
                value: PLANCK_TIME.to_string(),
            },
            Constant {
                name: "PLANCK_TEMPERATURE",
                value: PLANCK_TEMPERATURE.to_string(),
            },
            Constant {
                name: "PLANCK_CHARGE",
                value: PLANCK_CHARGE.to_string(),
            },
            // --- Molar & thermodynamic ---
            Constant {
                name: "MOLAR_MASS_CONSTANT",
                value: MOLAR_MASS_CONSTANT.to_string(),
            },
            Constant {
                name: "MOLAR_PLANCK_CONSTANT",
                value: MOLAR_PLANCK_CONSTANT.to_string(),
            },
            Constant {
                name: "LOSCHMIDT_CONSTANT",
                value: LOSCHMIDT_CONSTANT.to_string(),
            },
            Constant {
                name: "MOLAR_VOLUME_IDEAL_GAS",
                value: MOLAR_VOLUME_IDEAL_GAS.to_string(),
            },
            Constant {
                name: "SACKUR_TETRODE_CONSTANT",
                value: SACKUR_TETRODE_CONSTANT.to_string(),
            },
            // --- Electromagnetic additional ---
            Constant {
                name: "IMPEDANCE_OF_FREE_SPACE",
                value: IMPEDANCE_OF_FREE_SPACE.to_string(),
            },
            Constant {
                name: "INVERSE_FINE_STRUCTURE",
                value: INVERSE_FINE_STRUCTURE.to_string(),
            },
            Constant {
                name: "ELECTRON_CHARGE_TO_MASS",
                value: ELECTRON_CHARGE_TO_MASS.to_string(),
            },
            Constant {
                name: "PROTON_CHARGE_TO_MASS",
                value: PROTON_CHARGE_TO_MASS.to_string(),
            },
            // --- Atomic units ---
            Constant {
                name: "ATOMIC_UNIT_OF_LENGTH",
                value: ATOMIC_UNIT_OF_LENGTH.to_string(),
            },
            Constant {
                name: "ATOMIC_UNIT_OF_TIME",
                value: ATOMIC_UNIT_OF_TIME.to_string(),
            },
            Constant {
                name: "ATOMIC_UNIT_OF_VELOCITY",
                value: ATOMIC_UNIT_OF_VELOCITY.to_string(),
            },
            Constant {
                name: "ATOMIC_UNIT_OF_FORCE",
                value: ATOMIC_UNIT_OF_FORCE.to_string(),
            },
            Constant {
                name: "ATOMIC_UNIT_OF_ELECTRIC_FIELD",
                value: ATOMIC_UNIT_OF_ELECTRIC_FIELD.to_string(),
            },
            Constant {
                name: "ATOMIC_UNIT_OF_POLARIZABILITY",
                value: ATOMIC_UNIT_OF_POLARIZABILITY.to_string(),
            },
            // --- Boson masses & MeV forms ---
            Constant {
                name: "W_BOSON_MASS_GEV",
                value: W_BOSON_MASS_GEV.to_string(),
            },
            Constant {
                name: "Z_BOSON_MASS_GEV",
                value: Z_BOSON_MASS_GEV.to_string(),
            },
            Constant {
                name: "HIGGS_BOSON_MASS_GEV",
                value: HIGGS_BOSON_MASS_GEV.to_string(),
            },
            Constant {
                name: "ELECTRON_MASS_MEV",
                value: ELECTRON_MASS_MEV.to_string(),
            },
            Constant {
                name: "PROTON_MASS_MEV",
                value: PROTON_MASS_MEV.to_string(),
            },
            Constant {
                name: "NEUTRON_MASS_MEV",
                value: NEUTRON_MASS_MEV.to_string(),
            },
            Constant {
                name: "MUON_MASS_MEV",
                value: MUON_MASS_MEV.to_string(),
            },
            // --- Reduced Compton wavelengths ---
            Constant {
                name: "ELECTRON_REDUCED_COMPTON",
                value: ELECTRON_REDUCED_COMPTON.to_string(),
            },
            Constant {
                name: "PROTON_REDUCED_COMPTON",
                value: PROTON_REDUCED_COMPTON.to_string(),
            },
            Constant {
                name: "NEUTRON_REDUCED_COMPTON",
                value: NEUTRON_REDUCED_COMPTON.to_string(),
            },
            // --- Gas constant variant ---
            Constant {
                name: "GAS_CONSTANT_L_ATM",
                value: GAS_CONSTANT_L_ATM.to_string(),
            },
        ]);

        Self { constants }
    }

    /// Returns `true` if the `Constants` structure is valid.
    /// Otherwise, returns `false`.
    pub fn is_valid(&self) -> bool {
        self.constants().iter().all(|constant| {
            !constant.name.is_empty() && !constant.value.is_empty()
        })
    }
}

#[cfg(feature = "std")]
impl Default for Constants {
    fn default() -> Self {
        Self::new()
    }
}

/// Enum to represent the different constant values.
/// Requires the `std` feature.
#[cfg(feature = "std")]
#[derive(Debug, Clone, Serialize)]
pub enum ConstantValue {
    /// A float value represented as `f64`.
    Float(f64),
    /// A string value.
    String(String),
    /// An unsigned 32-bit integer value represented as `u32`.
    U32(u32),
    /// An unsigned integer with the size of a pointer represented
    /// as `usize`.
    Usize(usize),
    /// An array of characters represented as `&'static [char]`.
    CharArray(&'static [char]),
}

#[cfg(feature = "std")]
impl core::fmt::Display for ConstantValue {
    fn fmt(
        &self,
        f: &mut core::fmt::Formatter<'_>,
    ) -> core::fmt::Result {
        match self {
            Self::Float(v) => write!(f, "{v}"),
            Self::String(v) => write!(f, "{v}"),
            Self::U32(v) => write!(f, "{v}"),
            Self::Usize(v) => write!(f, "{v}"),
            Self::CharArray(v) => {
                for ch in *v {
                    write!(f, "{ch}")?;
                }
                Ok(())
            }
        }
    }
}

/// Constant category for [`CONSTANTS_TABLE`].
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Category {
    /// Pure mathematical constant.
    Mathematical,
    /// Physical / SI constant (CODATA 2018).
    Physical,
    /// Cryptographic or utility constant.
    Cryptographic,
}

/// A static lookup table of all named float constants with
/// category metadata.
///
/// Available in `no_std`. Zero allocation. Use this for
/// compile-time constant lookup by name without the `std`
/// feature.
///
/// # Example
///
/// ```
/// use cmn::constants::{CONSTANTS_TABLE, Category};
///
/// let pi = CONSTANTS_TABLE.iter()
///     .find(|(name, _, _)| *name == "PI")
///     .map(|(_, val, _)| *val);
/// assert_eq!(pi, Some(core::f64::consts::PI));
///
/// // Filter by category
/// let physical: Vec<_> = CONSTANTS_TABLE.iter()
///     .filter(|(_, _, cat)| *cat == Category::Physical)
///     .collect();
/// assert!(physical.len() > 10);
/// ```
use Category::{Mathematical as M, Physical as P};
/// A static lookup table of all named float constants.
pub const CONSTANTS_TABLE: &[(&str, f64, Category)] = &[
    ("APERY", APERY, M),
    ("AVOGADRO", AVOGADRO, P),
    ("BOLTZMANN", BOLTZMANN, P),
    ("CATALAN", CATALAN, M),
    ("COULOMB", COULOMB, P),
    ("EULER", EULER, M),
    ("FARADAY", FARADAY, P),
    ("GAMMA", GAMMA, M),
    ("GAS_CONSTANT", GAS_CONSTANT, P),
    ("GLAISHER_KINKELIN", GLAISHER_KINKELIN, M),
    ("GRAVITATIONAL_CONSTANT", GRAVITATIONAL_CONSTANT, P),
    ("KHINCHIN", KHINCHIN, M),
    ("PHI", PHI, M),
    ("PI", PI, M),
    ("PLANCK", PLANCK, P),
    ("PLANCK_REDUCED", PLANCK_REDUCED, P),
    ("SILVER_RATIO", SILVER_RATIO, M),
    ("SPEED_OF_LIGHT", SPEED_OF_LIGHT, P),
    ("SQRT2", SQRT2, M),
    ("SQRT3", SQRT3, M),
    ("SQRT5", SQRT5, M),
    ("TAU", TAU, M),
    ("VACUUM_PERMEABILITY", VACUUM_PERMEABILITY, P),
    ("VACUUM_PERMITTIVITY", VACUUM_PERMITTIVITY, P),
    ("LN_2", LN_2, M),
    ("LN_10", LN_10, M),
    ("LOG2_E", LOG2_E, M),
    ("LOG10_E", LOG10_E, M),
    ("FRAC_1_SQRT_2", FRAC_1_SQRT_2, M),
    ("FRAC_1_PI", FRAC_1_PI, M),
    ("FRAC_2_PI", FRAC_2_PI, M),
    ("FRAC_2_SQRT_PI", FRAC_2_SQRT_PI, M),
    ("FRAC_PI_2", FRAC_PI_2, M),
    ("FRAC_PI_3", FRAC_PI_3, M),
    ("FRAC_PI_4", FRAC_PI_4, M),
    ("FRAC_PI_6", FRAC_PI_6, M),
    ("FRAC_PI_8", FRAC_PI_8, M),
    ("ELEMENTARY_CHARGE", ELEMENTARY_CHARGE, P),
    ("ELECTRON_MASS", ELECTRON_MASS, P),
    ("PROTON_MASS", PROTON_MASS, P),
    ("NEUTRON_MASS", NEUTRON_MASS, P),
    ("STEFAN_BOLTZMANN", STEFAN_BOLTZMANN, P),
    ("WIEN_DISPLACEMENT", WIEN_DISPLACEMENT, P),
    ("STANDARD_GRAVITY", STANDARD_GRAVITY, P),
    ("STANDARD_ATMOSPHERE", STANDARD_ATMOSPHERE, P),
    ("ATOMIC_MASS_UNIT", ATOMIC_MASS_UNIT, P),
    ("BOHR_RADIUS", BOHR_RADIUS, P),
    ("FINE_STRUCTURE", FINE_STRUCTURE, P),
    ("RYDBERG", RYDBERG, P),
    ("MAGNETIC_FLUX_QUANTUM", MAGNETIC_FLUX_QUANTUM, P),
    ("CONDUCTANCE_QUANTUM", CONDUCTANCE_QUANTUM, P),
    ("MUON_MASS", MUON_MASS, P),
    ("TAU_PARTICLE_MASS", TAU_PARTICLE_MASS, P),
    ("DEUTERON_MASS", DEUTERON_MASS, P),
    ("TRITON_MASS", TRITON_MASS, P),
    ("HELION_MASS", HELION_MASS, P),
    ("ALPHA_PARTICLE_MASS", ALPHA_PARTICLE_MASS, P),
    ("ELECTRON_PROTON_MASS_RATIO", ELECTRON_PROTON_MASS_RATIO, P),
    ("PROTON_ELECTRON_MASS_RATIO", PROTON_ELECTRON_MASS_RATIO, P),
    ("MUON_ELECTRON_MASS_RATIO", MUON_ELECTRON_MASS_RATIO, P),
    ("NEUTRON_PROTON_MASS_RATIO", NEUTRON_PROTON_MASS_RATIO, P),
    ("DEUTERON_PROTON_MASS_RATIO", DEUTERON_PROTON_MASS_RATIO, P),
    ("BOHR_MAGNETON", BOHR_MAGNETON, P),
    ("NUCLEAR_MAGNETON", NUCLEAR_MAGNETON, P),
    ("ELECTRON_MAGNETIC_MOMENT", ELECTRON_MAGNETIC_MOMENT, P),
    ("PROTON_MAGNETIC_MOMENT", PROTON_MAGNETIC_MOMENT, P),
    ("NEUTRON_MAGNETIC_MOMENT", NEUTRON_MAGNETIC_MOMENT, P),
    ("ELECTRON_G_FACTOR", ELECTRON_G_FACTOR, P),
    ("PROTON_G_FACTOR", PROTON_G_FACTOR, P),
    ("ELECTRON_VOLT", ELECTRON_VOLT, P),
    ("EV_TO_KG", EV_TO_KG, P),
    ("EV_TO_AMU", EV_TO_AMU, P),
    ("EV_TO_HZ", EV_TO_HZ, P),
    ("EV_TO_KELVIN", EV_TO_KELVIN, P),
    ("EV_TO_INVERSE_METER", EV_TO_INVERSE_METER, P),
    ("CLASSICAL_ELECTRON_RADIUS", CLASSICAL_ELECTRON_RADIUS, P),
    (
        "ELECTRON_COMPTON_WAVELENGTH",
        ELECTRON_COMPTON_WAVELENGTH,
        P,
    ),
    ("PROTON_COMPTON_WAVELENGTH", PROTON_COMPTON_WAVELENGTH, P),
    ("NEUTRON_COMPTON_WAVELENGTH", NEUTRON_COMPTON_WAVELENGTH, P),
    ("THOMSON_CROSS_SECTION", THOMSON_CROSS_SECTION, P),
    ("FIRST_RADIATION_CONSTANT", FIRST_RADIATION_CONSTANT, P),
    ("SECOND_RADIATION_CONSTANT", SECOND_RADIATION_CONSTANT, P),
    ("JOSEPHSON_CONSTANT", JOSEPHSON_CONSTANT, P),
    ("VON_KLITZING_CONSTANT", VON_KLITZING_CONSTANT, P),
    ("HARTREE_ENERGY", HARTREE_ENERGY, P),
    ("HARTREE_ENERGY_EV", HARTREE_ENERGY_EV, P),
    ("PLANCK_MASS", PLANCK_MASS, P),
    ("PLANCK_LENGTH", PLANCK_LENGTH, P),
    ("PLANCK_TIME", PLANCK_TIME, P),
    ("PLANCK_TEMPERATURE", PLANCK_TEMPERATURE, P),
    ("PLANCK_CHARGE", PLANCK_CHARGE, P),
    ("MOLAR_MASS_CONSTANT", MOLAR_MASS_CONSTANT, P),
    ("MOLAR_PLANCK_CONSTANT", MOLAR_PLANCK_CONSTANT, P),
    ("LOSCHMIDT_CONSTANT", LOSCHMIDT_CONSTANT, P),
    ("MOLAR_VOLUME_IDEAL_GAS", MOLAR_VOLUME_IDEAL_GAS, P),
    ("SACKUR_TETRODE_CONSTANT", SACKUR_TETRODE_CONSTANT, P),
    ("IMPEDANCE_OF_FREE_SPACE", IMPEDANCE_OF_FREE_SPACE, P),
    ("INVERSE_FINE_STRUCTURE", INVERSE_FINE_STRUCTURE, P),
    ("ELECTRON_CHARGE_TO_MASS", ELECTRON_CHARGE_TO_MASS, P),
    ("PROTON_CHARGE_TO_MASS", PROTON_CHARGE_TO_MASS, P),
    ("ATOMIC_UNIT_OF_LENGTH", ATOMIC_UNIT_OF_LENGTH, P),
    ("ATOMIC_UNIT_OF_TIME", ATOMIC_UNIT_OF_TIME, P),
    ("ATOMIC_UNIT_OF_VELOCITY", ATOMIC_UNIT_OF_VELOCITY, P),
    ("ATOMIC_UNIT_OF_FORCE", ATOMIC_UNIT_OF_FORCE, P),
    (
        "ATOMIC_UNIT_OF_ELECTRIC_FIELD",
        ATOMIC_UNIT_OF_ELECTRIC_FIELD,
        P,
    ),
    (
        "ATOMIC_UNIT_OF_POLARIZABILITY",
        ATOMIC_UNIT_OF_POLARIZABILITY,
        P,
    ),
    ("W_BOSON_MASS_GEV", W_BOSON_MASS_GEV, P),
    ("Z_BOSON_MASS_GEV", Z_BOSON_MASS_GEV, P),
    ("HIGGS_BOSON_MASS_GEV", HIGGS_BOSON_MASS_GEV, P),
    ("ELECTRON_MASS_MEV", ELECTRON_MASS_MEV, P),
    ("PROTON_MASS_MEV", PROTON_MASS_MEV, P),
    ("NEUTRON_MASS_MEV", NEUTRON_MASS_MEV, P),
    ("MUON_MASS_MEV", MUON_MASS_MEV, P),
    ("ELECTRON_REDUCED_COMPTON", ELECTRON_REDUCED_COMPTON, P),
    ("PROTON_REDUCED_COMPTON", PROTON_REDUCED_COMPTON, P),
    ("NEUTRON_REDUCED_COMPTON", NEUTRON_REDUCED_COMPTON, P),
    ("GAS_CONSTANT_L_ATM", GAS_CONSTANT_L_ATM, P),
];

/// Apéry's constant, which is the sum of the reciprocals of the positive cubes.
/// ζ(3) ≈ 1.2020569032
pub const APERY: f64 = 1.2020569031595942;

/// Avogadro's constant (CODATA 2018, exact since 2019 SI).
/// N_A = 6.02214076 x 10^23 mol^-1
pub const AVOGADRO: f64 = 6.02214076e23;

/// Boltzmann's constant (CODATA 2018, exact since 2019 SI).
/// k_B = 1.380649 x 10^-23 J K^-1
pub const BOLTZMANN: f64 = 1.380_649e-23;

/// Catalan's constant, which is the sum of the alternating harmonic series.
/// C ≈ 0.915965594177219
pub const CATALAN: f64 = 0.915_965_594_177_219;

/// Coulomb's constant (CODATA 2018).
/// k_e ≈ 8.9875517923 x 10^9 N m^2 C^-2
pub const COULOMB: f64 = 8.9875517923e9;
/// Standard uncertainty of [`COULOMB`]. Source: CODATA 2018.
pub const COULOMB_UNCERTAINTY: f64 = 0.0;

/// The base of the natural logarithm, Euler's number.
/// e ≈ 2.7182818284590452353602874713527
pub const EULER: f64 = core::f64::consts::E;

/// Faraday constant (CODATA 2018, exact since 2019 SI).
/// F = N_A * e = 96485.33212 C mol^-1
pub const FARADAY: f64 = 96485.33212;

/// The Euler-Mascheroni constant, which is the limiting difference between the harmonic series and the natural logarithm.
/// γ ≈ 0.5772156649015329
pub const GAMMA: f64 = 0.5772156649015329;

/// The molar gas constant (CODATA 2018, exact since 2019 SI).
/// R = N_A * k_B = 8.314462618 J mol^-1 K^-1
pub const GAS_CONSTANT: f64 = 8.314462618;

/// Glaisher-Kinkelin constant, which arises in the asymptotic expansion of the Barnes G-function.
/// A ≈ 1.2824271291
pub const GLAISHER_KINKELIN: f64 = 1.2824271291006226;

/// The Newtonian gravitational constant (CODATA 2018).
/// G ≈ 6.67430 x 10^-11 m^3 kg^-1 s^-2
pub const GRAVITATIONAL_CONSTANT: f64 = 6.67430e-11;
/// Standard uncertainty of [`GRAVITATIONAL_CONSTANT`]. Source: CODATA 2018.
pub const GRAVITATIONAL_CONSTANT_UNCERTAINTY: f64 = 0.00015e-11;

/// The hash algorithm used. The default is Blake3.
pub const HASH_ALGORITHM: &str = "Blake3";

/// The cost of the hash algorithm. The default is 8.
pub const HASH_COST: u32 = 8;

/// The hash length is the length of the hash in bytes.
/// - The default is 32.
/// - The maximum is 64.
/// - The minimum is 16.
pub const HASH_LENGTH: usize = 32;

/// Khinchin's constant, which appears in the theory of continued fractions.
/// K ≈ 2.6854520010
pub const KHINCHIN: f64 = 2.6854520010653064;

/// The golden ratio, which is the limit of the ratio of consecutive Fibonacci numbers.
/// φ = (1 + √5) / 2 ≈ 1.6180339887498948482045868343656
pub const PHI: f64 = (1.0 + SQRT5) / 2.0;

/// The ratio of a circle's circumference to its diameter.
/// π ≈ 3.14159265358979323846264338327950288
pub const PI: f64 = core::f64::consts::PI;

/// Planck's constant (CODATA 2018, exact since 2019 SI).
/// h = 6.62607015 x 10^-34 J s
pub const PLANCK: f64 = 6.62607015e-34;

/// Planck's reduced constant, which is Planck's constant divided by 2π.
/// ħ = h / (2π) ≈ 1.054571817 x 10^-34 J s
pub const PLANCK_REDUCED: f64 = PLANCK / (2.0 * PI);

/// The silver ratio, which is one of the silver means.
/// δ_s = 1 + √2 ≈ 2.4142135623730950488016887242097
pub const SILVER_RATIO: f64 = 1.0 + SQRT2;

/// The speed of light in vacuum (exact since 1983 SI definition).
/// c = 299792458 m s^-1
pub const SPEED_OF_LIGHT: f64 = 299792458.0;

/// A set of special characters.
pub const SPECIAL_CHARS: &[char] = &[
    '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=',
    '[', ']', '{', '}', '|', ';', ':', '"', '<', '>', ',', '.', '?',
    '/', '~', '`',
];

/// The square root of 2.
/// √2 ≈ 1.4142135623730950488016887242097
pub const SQRT2: f64 = core::f64::consts::SQRT_2;

/// The square root of 3.
/// √3 ≈ 1.7320508075688772935274463415059
pub const SQRT3: f64 = 1.7320508075688772;

/// The square root of 5.
/// √5 ≈ 2.23606797749979
pub const SQRT5: f64 = 2.236_067_977_499_79;

/// The circle constant, which is the ratio of a circle's circumference to its radius.
/// τ = 2π ≈ 6.28318530717958647692528676655900577
pub const TAU: f64 = core::f64::consts::TAU;

/// The vacuum permeability (CODATA 2018).
/// μ_0 ≈ 1.25663706212 x 10^-6 N A^-2
pub const VACUUM_PERMEABILITY: f64 = 1.25663706212e-6;
/// Standard uncertainty of [`VACUUM_PERMEABILITY`]. Source: CODATA 2018.
pub const VACUUM_PERMEABILITY_UNCERTAINTY: f64 = 0.00000000019e-6;

/// The vacuum permittivity (CODATA 2018).
/// ε_0 ≈ 8.8541878128 x 10^-12 F m^-1
pub const VACUUM_PERMITTIVITY: f64 = 8.8541878128e-12;
/// Standard uncertainty of [`VACUUM_PERMITTIVITY`]. Source: CODATA 2018.
pub const VACUUM_PERMITTIVITY_UNCERTAINTY: f64 = 0.0000000013e-12;

// ---------------------------------------------------------------
// Mathematical constants from std::f64::consts
// ---------------------------------------------------------------

/// The natural logarithm of 2.
/// ln(2) ≈ 0.6931471805599453
pub const LN_2: f64 = core::f64::consts::LN_2;

/// The natural logarithm of 10.
/// ln(10) ≈ 2.302585092994046
pub const LN_10: f64 = core::f64::consts::LN_10;

/// The base-2 logarithm of Euler's number.
/// log₂(e) ≈ 1.4426950408889634
pub const LOG2_E: f64 = core::f64::consts::LOG2_E;

/// The base-10 logarithm of Euler's number.
/// log₁₀(e) ≈ 0.4342944819032518
pub const LOG10_E: f64 = core::f64::consts::LOG10_E;

/// The reciprocal of the square root of 2.
/// 1/√2 ≈ 0.7071067811865476
pub const FRAC_1_SQRT_2: f64 = core::f64::consts::FRAC_1_SQRT_2;

/// The reciprocal of pi.
/// 1/π ≈ 0.3183098861837907
pub const FRAC_1_PI: f64 = core::f64::consts::FRAC_1_PI;

/// Two divided by pi.
/// 2/π ≈ 0.6366197723675814
pub const FRAC_2_PI: f64 = core::f64::consts::FRAC_2_PI;

/// Two divided by the square root of pi.
/// 2/√π ≈ 1.1283791670955126
pub const FRAC_2_SQRT_PI: f64 = core::f64::consts::FRAC_2_SQRT_PI;

/// Pi divided by 2 (a right angle in radians).
/// π/2 ≈ 1.5707963267948966
pub const FRAC_PI_2: f64 = core::f64::consts::FRAC_PI_2;

/// Pi divided by 3 (60 degrees in radians).
/// π/3 ≈ 1.0471975511965979
pub const FRAC_PI_3: f64 = core::f64::consts::FRAC_PI_3;

/// Pi divided by 4 (45 degrees in radians).
/// π/4 ≈ 0.7853981633974483
pub const FRAC_PI_4: f64 = core::f64::consts::FRAC_PI_4;

/// Pi divided by 6 (30 degrees in radians).
/// π/6 ≈ 0.5235987755982989
pub const FRAC_PI_6: f64 = core::f64::consts::FRAC_PI_6;

/// Pi divided by 8 (22.5 degrees in radians).
/// π/8 ≈ 0.39269908169872414
pub const FRAC_PI_8: f64 = core::f64::consts::FRAC_PI_8;

// ---------------------------------------------------------------
// Physical constants — CODATA 2018 recommended values
// ---------------------------------------------------------------

/// The elementary charge (CODATA 2018, exact since 2019 SI).
/// e = 1.602176634 x 10^-19 C
pub const ELEMENTARY_CHARGE: f64 = 1.602_176_634e-19;

/// The rest mass of an electron (CODATA 2018).
/// m_e ≈ 9.1093837015 x 10^-31 kg
pub const ELECTRON_MASS: f64 = 9.109_383_701_5e-31;
/// Standard uncertainty of [`ELECTRON_MASS`]. Source: CODATA 2018.
pub const ELECTRON_MASS_UNCERTAINTY: f64 = 0.000_000_002_8e-31;

/// The rest mass of a proton (CODATA 2018).
/// m_p ≈ 1.67262192369 x 10^-27 kg
pub const PROTON_MASS: f64 = 1.672_621_923_69e-27;
/// Standard uncertainty of [`PROTON_MASS`]. Source: CODATA 2018.
pub const PROTON_MASS_UNCERTAINTY: f64 = 0.000_000_000_51e-27;

/// The rest mass of a neutron (CODATA 2018).
/// m_n ≈ 1.67492749804 x 10^-27 kg
pub const NEUTRON_MASS: f64 = 1.674_927_498_04e-27;
/// Standard uncertainty of [`NEUTRON_MASS`]. Source: CODATA 2018.
pub const NEUTRON_MASS_UNCERTAINTY: f64 = 0.000_000_000_95e-27;

/// The Stefan-Boltzmann constant (CODATA 2018, exact since 2019 SI).
/// σ = 5.670374419 x 10^-8 W m^-2 K^-4
pub const STEFAN_BOLTZMANN: f64 = 5.670_374_419e-8;

/// Wien's displacement constant (CODATA 2018).
/// b ≈ 2.897771955 x 10^-3 m K
pub const WIEN_DISPLACEMENT: f64 = 2.897_771_955e-3;
/// Standard uncertainty of [`WIEN_DISPLACEMENT`]. Source: CODATA 2018.
pub const WIEN_DISPLACEMENT_UNCERTAINTY: f64 = 0.000_000_013e-3;

/// Standard acceleration of gravity (exact by definition).
/// g = 9.80665 m s^-2
pub const STANDARD_GRAVITY: f64 = 9.806_65;

/// Standard atmosphere pressure (exact by definition).
/// atm = 101325 Pa
pub const STANDARD_ATMOSPHERE: f64 = 101_325.0;

/// The unified atomic mass unit / dalton (CODATA 2018).
/// u ≈ 1.66053906660 x 10^-27 kg
pub const ATOMIC_MASS_UNIT: f64 = 1.660_539_066_60e-27;
/// Standard uncertainty of [`ATOMIC_MASS_UNIT`]. Source: CODATA 2018.
pub const ATOMIC_MASS_UNIT_UNCERTAINTY: f64 = 0.000_000_000_50e-27;

/// The Bohr radius (CODATA 2018).
/// a_0 ≈ 5.29177210903 x 10^-11 m
pub const BOHR_RADIUS: f64 = 5.291_772_109_03e-11;
/// Standard uncertainty of [`BOHR_RADIUS`]. Source: CODATA 2018.
pub const BOHR_RADIUS_UNCERTAINTY: f64 = 0.000_000_000_80e-11;

/// The fine-structure constant (CODATA 2018).
/// α ≈ 7.2973525693 x 10^-3 (dimensionless)
pub const FINE_STRUCTURE: f64 = 7.297_352_569_3e-3;
/// Standard uncertainty of [`FINE_STRUCTURE`]. Source: CODATA 2018.
pub const FINE_STRUCTURE_UNCERTAINTY: f64 = 0.000_000_001_1e-3;

/// The Rydberg constant (CODATA 2018).
/// R∞ ≈ 10973731.568160 m^-1
pub const RYDBERG: f64 = 10_973_731.568_160;
/// Standard uncertainty of [`RYDBERG`]. Source: CODATA 2018.
pub const RYDBERG_UNCERTAINTY: f64 = 0.000_021;

/// The magnetic flux quantum (CODATA 2018, exact since 2019 SI).
/// Φ_0 = h/(2e) = 2.067833848 x 10^-15 Wb
pub const MAGNETIC_FLUX_QUANTUM: f64 = 2.067_833_848e-15;

/// The conductance quantum (CODATA 2018, exact since 2019 SI).
/// G_0 = 2e²/h = 7.748091729 x 10^-5 S
pub const CONDUCTANCE_QUANTUM: f64 = 7.748_091_729e-5;

// ---------------------------------------------------------------
// Particle masses — CODATA 2018
// ---------------------------------------------------------------

/// Muon mass (CODATA 2018).
/// m_μ ≈ 1.883531627e-28 kg
pub const MUON_MASS: f64 = 1.883_531_627e-28;

/// Tau lepton mass (CODATA 2018).
/// m_τ ≈ 3.16754e-27 kg
pub const TAU_PARTICLE_MASS: f64 = 3.167_54e-27;

/// Deuteron mass (CODATA 2018).
/// m_d ≈ 3.3435837724e-27 kg
pub const DEUTERON_MASS: f64 = 3.343_583_772_4e-27;

/// Triton mass (CODATA 2018).
/// m_t ≈ 5.0073567446e-27 kg
pub const TRITON_MASS: f64 = 5.007_356_744_6e-27;

/// Helion (He-3 nucleus) mass (CODATA 2018).
/// m_h ≈ 5.0064127796e-27 kg
pub const HELION_MASS: f64 = 5.006_412_779_6e-27;

/// Alpha particle mass (CODATA 2018).
/// m_α ≈ 6.6446573357e-27 kg
pub const ALPHA_PARTICLE_MASS: f64 = 6.644_657_335_7e-27;

// ---------------------------------------------------------------
// Mass ratios — CODATA 2018
// ---------------------------------------------------------------

/// Electron-to-proton mass ratio (CODATA 2018).
/// m_e / m_p ≈ 5.44617021487e-4
pub const ELECTRON_PROTON_MASS_RATIO: f64 = 5.446_170_214_87e-4;

/// Proton-to-electron mass ratio (CODATA 2018).
/// m_p / m_e ≈ 1836.15267343
pub const PROTON_ELECTRON_MASS_RATIO: f64 = 1_836.152_673_43;

/// Muon-to-electron mass ratio (CODATA 2018).
/// m_μ / m_e ≈ 206.7682830
pub const MUON_ELECTRON_MASS_RATIO: f64 = 206.768_283_0;

/// Neutron-to-proton mass ratio (CODATA 2018).
/// m_n / m_p ≈ 1.00137841931
pub const NEUTRON_PROTON_MASS_RATIO: f64 = 1.001_378_419_31;

/// Deuteron-to-proton mass ratio (CODATA 2018).
/// m_d / m_p ≈ 1.99900750139
pub const DEUTERON_PROTON_MASS_RATIO: f64 = 1.999_007_501_39;

// ---------------------------------------------------------------
// Magnetic moments — CODATA 2018
// ---------------------------------------------------------------

/// Bohr magneton (CODATA 2018).
/// μ_B = eℏ/(2m_e) ≈ 9.2740100783e-24 J/T
pub const BOHR_MAGNETON: f64 = 9.274_010_078_3e-24;

/// Nuclear magneton (CODATA 2018).
/// μ_N = eℏ/(2m_p) ≈ 5.0507837461e-27 J/T
pub const NUCLEAR_MAGNETON: f64 = 5.050_783_746_1e-27;

/// Electron magnetic moment (CODATA 2018).
/// μ_e ≈ -9.2847647043e-24 J/T
pub const ELECTRON_MAGNETIC_MOMENT: f64 = -9.284_764_704_3e-24;

/// Proton magnetic moment (CODATA 2018).
/// μ_p ≈ 1.41060679736e-26 J/T
pub const PROTON_MAGNETIC_MOMENT: f64 = 1.410_606_797_36e-26;

/// Neutron magnetic moment (CODATA 2018).
/// μ_n ≈ -9.6623651e-27 J/T
pub const NEUTRON_MAGNETIC_MOMENT: f64 = -9.662_365_1e-27;

/// Electron g-factor (CODATA 2018).
/// g_e ≈ -2.00231930436256
pub const ELECTRON_G_FACTOR: f64 = -2.002_319_304_362_56;

/// Proton g-factor (CODATA 2018).
/// g_p ≈ 5.5856946893
pub const PROTON_G_FACTOR: f64 = 5.585_694_689_3;

// ---------------------------------------------------------------
// Electron volt equivalents — CODATA 2018 (exact since 2019)
// ---------------------------------------------------------------

/// Electron volt in joules (CODATA 2018, exact).
/// 1 eV = 1.602176634e-19 J
pub const ELECTRON_VOLT: f64 = 1.602_176_634e-19;

/// Electron volt–kilogram relationship (exact).
/// 1 eV/c² ≈ 1.782661921e-36 kg
pub const EV_TO_KG: f64 = 1.782_661_921e-36;

/// Electron volt–atomic mass unit relationship.
/// 1 eV/c² ≈ 1.07354410233e-9 u
pub const EV_TO_AMU: f64 = 1.073_544_102_33e-9;

/// Electron volt–hertz relationship (exact).
/// 1 eV/h ≈ 2.417989242e14 Hz
pub const EV_TO_HZ: f64 = 2.417_989_242e14;

/// Electron volt–kelvin relationship (exact).
/// 1 eV/k_B ≈ 1.160451812e4 K
pub const EV_TO_KELVIN: f64 = 1.160_451_812e4;

/// Electron volt–inverse meter relationship (exact).
/// 1 eV/(hc) ≈ 8.065543937e5 /m
pub const EV_TO_INVERSE_METER: f64 = 8.065_543_937e5;

// ---------------------------------------------------------------
// Atomic & nuclear constants — CODATA 2018
// ---------------------------------------------------------------

/// Classical electron radius (CODATA 2018).
/// r_e = α²a_0 ≈ 2.8179403262e-15 m
pub const CLASSICAL_ELECTRON_RADIUS: f64 = 2.817_940_326_2e-15;

/// Compton wavelength of the electron (CODATA 2018).
/// λ_C = h/(m_e c) ≈ 2.42631023867e-12 m
pub const ELECTRON_COMPTON_WAVELENGTH: f64 = 2.426_310_238_67e-12;

/// Compton wavelength of the proton (CODATA 2018).
/// λ_C,p = h/(m_p c) ≈ 1.32140985539e-15 m
pub const PROTON_COMPTON_WAVELENGTH: f64 = 1.321_409_855_39e-15;

/// Compton wavelength of the neutron (CODATA 2018).
/// λ_C,n = h/(m_n c) ≈ 1.31959090581e-15 m
pub const NEUTRON_COMPTON_WAVELENGTH: f64 = 1.319_590_905_81e-15;

/// Thomson cross section (CODATA 2018).
/// σ_T = (8π/3)r_e² ≈ 6.6524587321e-29 m²
pub const THOMSON_CROSS_SECTION: f64 = 6.652_458_732_1e-29;

/// First radiation constant (CODATA 2018).
/// c_1 = 2πhc² ≈ 3.741771852e-16 W m²
pub const FIRST_RADIATION_CONSTANT: f64 = 3.741_771_852e-16;

/// Second radiation constant (CODATA 2018).
/// c_2 = hc/k_B ≈ 1.438776877e-2 m K
pub const SECOND_RADIATION_CONSTANT: f64 = 1.438_776_877e-2;

/// Josephson constant (CODATA 2018, exact since 2019 SI).
/// K_J = 2e/h ≈ 4.835978484e14 Hz/V
pub const JOSEPHSON_CONSTANT: f64 = 4.835_978_484e14;

/// Von Klitzing constant (CODATA 2018, exact since 2019 SI).
/// R_K = h/e² ≈ 25812.80745 Ω
pub const VON_KLITZING_CONSTANT: f64 = 25_812.807_45;

/// Hartree energy (CODATA 2018).
/// E_h = m_e c² α² ≈ 4.3597447222071e-18 J
pub const HARTREE_ENERGY: f64 = 4.359_744_722_207_1e-18;

/// Hartree energy in eV (CODATA 2018).
/// E_h ≈ 27.211386245988 eV
pub const HARTREE_ENERGY_EV: f64 = 27.211_386_245_988;

// ---------------------------------------------------------------
// Planck units — derived from fundamental constants
// ---------------------------------------------------------------

/// Planck mass.
/// m_P = √(ℏc/G) ≈ 2.176434e-8 kg
pub const PLANCK_MASS: f64 = 2.176_434e-8;

/// Planck length.
/// l_P = √(ℏG/c³) ≈ 1.616255e-35 m
pub const PLANCK_LENGTH: f64 = 1.616_255e-35;

/// Planck time.
/// t_P = √(ℏG/c⁵) ≈ 5.391247e-44 s
pub const PLANCK_TIME: f64 = 5.391_247e-44;

/// Planck temperature.
/// T_P = m_P c²/k_B ≈ 1.416784e32 K
pub const PLANCK_TEMPERATURE: f64 = 1.416_784e32;

/// Planck charge.
/// q_P = √(4πε₀ℏc) ≈ 1.875546e-18 C
pub const PLANCK_CHARGE: f64 = 1.875_546e-18;

// ---------------------------------------------------------------
// Molar & thermodynamic — CODATA 2018
// ---------------------------------------------------------------

/// Molar mass constant (CODATA 2018).
/// M_u ≈ 0.99999999965e-3 kg/mol
pub const MOLAR_MASS_CONSTANT: f64 = 0.999_999_999_65e-3;

/// Molar Planck constant (exact).
/// N_A h ≈ 3.990312712e-10 J s/mol
pub const MOLAR_PLANCK_CONSTANT: f64 = 3.990_312_712e-10;

/// Loschmidt constant at 273.15 K, 101.325 kPa.
/// n_0 ≈ 2.6867774e25 /m³
pub const LOSCHMIDT_CONSTANT: f64 = 2.686_777_4e25;

/// Molar volume of ideal gas at STP (273.15 K, 100 kPa).
/// V_m ≈ 22.71095e-3 m³/mol
pub const MOLAR_VOLUME_IDEAL_GAS: f64 = 22.710_95e-3;

/// Sackur-Tetrode constant at 1 K, 101.325 kPa.
/// S_0/R ≈ -1.15170753706
pub const SACKUR_TETRODE_CONSTANT: f64 = -1.151_707_537_06;

// ---------------------------------------------------------------
// Electromagnetic — additional CODATA 2018
// ---------------------------------------------------------------

/// Impedance of free space (CODATA 2018).
/// Z_0 = μ₀c ≈ 376.730313668 Ω
pub const IMPEDANCE_OF_FREE_SPACE: f64 = 376.730_313_668;

/// Inverse fine-structure constant (CODATA 2018).
/// 1/α ≈ 137.035999084
pub const INVERSE_FINE_STRUCTURE: f64 = 137.035_999_084;

/// Electron charge-to-mass quotient (CODATA 2018).
/// e/m_e ≈ -1.75882001076e11 C/kg
pub const ELECTRON_CHARGE_TO_MASS: f64 = -1.758_820_010_76e11;

/// Proton charge-to-mass quotient (CODATA 2018).
/// e/m_p ≈ 9.5788332e7 C/kg
pub const PROTON_CHARGE_TO_MASS: f64 = 9.578_833_2e7;

// ---------------------------------------------------------------
// Atomic unit conversions — CODATA 2018
// ---------------------------------------------------------------

/// Atomic unit of length (= Bohr radius).
/// a_0 ≈ 5.29177210903e-11 m
pub const ATOMIC_UNIT_OF_LENGTH: f64 = BOHR_RADIUS;

/// Atomic unit of time.
/// ℏ/E_h ≈ 2.4188843265857e-17 s
pub const ATOMIC_UNIT_OF_TIME: f64 = 2.418_884_326_585_7e-17;

/// Atomic unit of velocity.
/// a_0 E_h/ℏ ≈ 2.18769126364e6 m/s
pub const ATOMIC_UNIT_OF_VELOCITY: f64 = 2.187_691_263_64e6;

/// Atomic unit of force.
/// E_h/a_0 ≈ 8.2387234983e-8 N
pub const ATOMIC_UNIT_OF_FORCE: f64 = 8.238_723_498_3e-8;

/// Atomic unit of electric field.
/// E_h/(ea_0) ≈ 5.14220674763e11 V/m
pub const ATOMIC_UNIT_OF_ELECTRIC_FIELD: f64 = 5.142_206_747_63e11;

/// Atomic unit of electric polarizability.
/// e²a₀²/E_h ≈ 1.64877727436e-41 C²m²/J
pub const ATOMIC_UNIT_OF_POLARIZABILITY: f64 = 1.648_777_274_36e-41;

// ---------------------------------------------------------------
// Particle masses in MeV/c² and boson masses
// ---------------------------------------------------------------

/// W boson mass (PDG 2022).
/// m_W ≈ 80.377 GeV/c²
pub const W_BOSON_MASS_GEV: f64 = 80.377;

/// Z boson mass (PDG 2022).
/// m_Z ≈ 91.1876 GeV/c²
pub const Z_BOSON_MASS_GEV: f64 = 91.1876;

/// Higgs boson mass (PDG 2022).
/// m_H ≈ 125.25 GeV/c²
pub const HIGGS_BOSON_MASS_GEV: f64 = 125.25;

/// Electron mass in MeV/c² (CODATA 2018).
/// m_e c² ≈ 0.51099895000 MeV
pub const ELECTRON_MASS_MEV: f64 = 0.510_998_950_00;

/// Proton mass in MeV/c² (CODATA 2018).
/// m_p c² ≈ 938.27208816 MeV
pub const PROTON_MASS_MEV: f64 = 938.272_088_16;

/// Neutron mass in MeV/c² (CODATA 2018).
/// m_n c² ≈ 939.56542052 MeV
pub const NEUTRON_MASS_MEV: f64 = 939.565_420_52;

/// Muon mass in MeV/c² (CODATA 2018).
/// m_μ c² ≈ 105.6583755 MeV
pub const MUON_MASS_MEV: f64 = 105.658_375_5;

// ---------------------------------------------------------------
// Reduced Compton wavelengths (λ̄ = ℏ/(mc))
// ---------------------------------------------------------------

/// Reduced Compton wavelength of the electron.
/// λ̄_e = ℏ/(m_e c) ≈ 3.8615926796e-13 m
pub const ELECTRON_REDUCED_COMPTON: f64 = 3.861_592_679_6e-13;

/// Reduced Compton wavelength of the proton.
/// λ̄_p = ℏ/(m_p c) ≈ 2.10308910336e-16 m
pub const PROTON_REDUCED_COMPTON: f64 = 2.103_089_103_36e-16;

/// Reduced Compton wavelength of the neutron.
/// λ̄_n = ℏ/(m_n c) ≈ 2.10019415600e-16 m
pub const NEUTRON_REDUCED_COMPTON: f64 = 2.100_194_156_00e-16;

// ---------------------------------------------------------------
// Molar gas constant in other units
// ---------------------------------------------------------------

/// Molar gas constant in L·atm/(mol·K).
/// R ≈ 0.08205736608 L·atm/(mol·K)
pub const GAS_CONSTANT_L_ATM: f64 = 0.082_057_366_08;