1 parent d08e860 commit d105b9bCopy full SHA for d105b9b
1 file changed
src/exact_math/scientific_mode.rs
@@ -2,11 +2,14 @@ use std::{f64, fmt::Display};
2
3
use crate::parsing::ast::int_to_superscript_string;
4
5
+/// # Science Float
6
+/// A float in scientific notation is a floating point value and an integer exponent.
7
pub struct ScienceFloat {
8
exponent: i32,
9
value: f64, //value * 10^exponent
10
}
11
12
+/// Implementation of the Display trait for the ScienceFloat struct.
13
impl Display for ScienceFloat {
14
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15
match self.exponent {
@@ -21,6 +24,9 @@ impl Display for ScienceFloat {
21
24
22
25
23
26
27
+/// # FromFloat
28
+/// Takes a floating point number
29
+/// Returns the scientific representation of that float.
30
pub fn from_float(f: f64) -> ScienceFloat {
31
let multiple;
32
let working_value;
0 commit comments