From 97b0fc2295adcdb1ba54e003227f486a92425acd Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sat, 28 Jan 2017 21:36:49 -0800 Subject: switch to sci notation for floats (except latex) --- src/repr_latex.rs | 3 +-- src/transpile_js.rs | 2 +- src/transpile_python.rs | 2 +- src/transpile_scheme.rs | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/repr_latex.rs b/src/repr_latex.rs index 51c9e7a..09bf549 100644 --- a/src/repr_latex.rs +++ b/src/repr_latex.rs @@ -53,7 +53,6 @@ r#"\({name}\) d.clone() } else { "".to_string() })); } - let rows = rows.join("\n"); Ok(format!( r#"
Variable @@ -64,7 +63,7 @@ r#" {rows}
"#, - rows = rows.join("\n ")) + rows = rows.join("\n "))) } } diff --git a/src/transpile_js.rs b/src/transpile_js.rs index 586abc1..282240b 100644 --- a/src/transpile_js.rs +++ b/src/transpile_js.rs @@ -105,7 +105,7 @@ impl TranspileJS for Expr { use modelica_parser::Expr::*; match *self { Integer(e) => Ok(format!("{}", e)), - Float(e) => Ok(format!("{}", e)), + Float(e) => Ok(format!("{:e}", e)), Boolean(true) => Ok(format!("true")), Boolean(false) => Ok(format!("false")), StringLiteral(ref s) => Ok(format!("\"{}\"", s)), diff --git a/src/transpile_python.rs b/src/transpile_python.rs index d980e60..f38f699 100644 --- a/src/transpile_python.rs +++ b/src/transpile_python.rs @@ -122,7 +122,7 @@ impl TranspilePython for Expr { use modelica_parser::BinOperator::*; match *self { Integer(e) => Ok(format!("{}", e)), - Float(e) => Ok(format!("{}", e)), + Float(e) => Ok(format!("{:e}", e)), Boolean(true) => Ok(format!("True")), Boolean(false) => Ok(format!("False")), StringLiteral(ref s) => Ok(format!("\"{}\"", s)), diff --git a/src/transpile_scheme.rs b/src/transpile_scheme.rs index d6f437a..57bc932 100644 --- a/src/transpile_scheme.rs +++ b/src/transpile_scheme.rs @@ -53,7 +53,7 @@ impl TranspileScheme for Expr { use modelica_parser::Expr::*; match *self { Integer(e) => Ok(format!("{}", e)), - Float(e) => Ok(format!("{}", e)), + Float(e) => Ok(format!("{:e}", e)), Boolean(true) => Ok(format!("#t")), Boolean(false) => Ok(format!("#f")), StringLiteral(ref s) => Ok(format!("\"{}\"", s)), -- cgit v1.2.3