Remove Float trait.
This commit is contained in:
parent
e5249cc1ae
commit
60f8a7f91c
@ -1480,9 +1480,6 @@ impl fmt::Debug for FloatWrapper {
|
|||||||
impl fmt::Display for FloatWrapper {
|
impl fmt::Display for FloatWrapper {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
#[cfg(feature = "no_std")]
|
|
||||||
use num_traits::Float;
|
|
||||||
|
|
||||||
let abs = self.0.abs();
|
let abs = self.0.abs();
|
||||||
if abs > 10000000000000.0 || abs < 0.0000000000001 {
|
if abs > 10000000000000.0 || abs < 0.0000000000001 {
|
||||||
write!(f, "{:e}", self.0)
|
write!(f, "{:e}", self.0)
|
||||||
|
@ -8,7 +8,7 @@ use crate::stdlib::{
|
|||||||
fmt,
|
fmt,
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
string::String,
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
use crate::{FnPtr, ImmutableString, INT};
|
use crate::{FnPtr, ImmutableString, INT};
|
||||||
|
|
||||||
|
@ -11,10 +11,6 @@ use crate::FLOAT;
|
|||||||
#[cfg(feature = "decimal")]
|
#[cfg(feature = "decimal")]
|
||||||
use rust_decimal::Decimal;
|
use rust_decimal::Decimal;
|
||||||
|
|
||||||
#[cfg(feature = "no_std")]
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
|
||||||
use num_traits::float::Float;
|
|
||||||
|
|
||||||
/// Is the type a numeric type?
|
/// Is the type a numeric type?
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn is_numeric(type_id: TypeId) -> bool {
|
fn is_numeric(type_id: TypeId) -> bool {
|
||||||
|
@ -7,10 +7,6 @@ use crate::{def_package, EvalAltResult, Position, INT};
|
|||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
use crate::FLOAT;
|
use crate::FLOAT;
|
||||||
|
|
||||||
#[cfg(feature = "no_std")]
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
|
||||||
use num_traits::float::Float;
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn make_err(msg: impl Into<String>) -> Box<EvalAltResult> {
|
pub fn make_err(msg: impl Into<String>) -> Box<EvalAltResult> {
|
||||||
EvalAltResult::ErrorArithmetic(msg.into(), Position::NONE).into()
|
EvalAltResult::ErrorArithmetic(msg.into(), Position::NONE).into()
|
||||||
|
@ -9,10 +9,6 @@ use crate::FLOAT;
|
|||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
use crate::result::EvalAltResult;
|
use crate::result::EvalAltResult;
|
||||||
|
|
||||||
#[cfg(feature = "no_std")]
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
|
||||||
use num_traits::float::Float;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
use crate::stdlib::format;
|
use crate::stdlib::format;
|
||||||
|
|
||||||
|
@ -57,9 +57,6 @@ mod print_debug_functions {
|
|||||||
pub mod float_functions {
|
pub mod float_functions {
|
||||||
#[rhai_fn(name = "print", name = "to_string")]
|
#[rhai_fn(name = "print", name = "to_string")]
|
||||||
pub fn print_f64(number: f64) -> ImmutableString {
|
pub fn print_f64(number: f64) -> ImmutableString {
|
||||||
#[cfg(feature = "no_std")]
|
|
||||||
use num_traits::Float;
|
|
||||||
|
|
||||||
let abs = number.abs();
|
let abs = number.abs();
|
||||||
if abs > 10000000000000.0 || abs < 0.0000000000001 {
|
if abs > 10000000000000.0 || abs < 0.0000000000001 {
|
||||||
format!("{:e}", number).into()
|
format!("{:e}", number).into()
|
||||||
@ -69,9 +66,6 @@ mod print_debug_functions {
|
|||||||
}
|
}
|
||||||
#[rhai_fn(name = "print", name = "to_string")]
|
#[rhai_fn(name = "print", name = "to_string")]
|
||||||
pub fn print_f32(number: f32) -> ImmutableString {
|
pub fn print_f32(number: f32) -> ImmutableString {
|
||||||
#[cfg(feature = "no_std")]
|
|
||||||
use num_traits::Float;
|
|
||||||
|
|
||||||
let abs = number.abs();
|
let abs = number.abs();
|
||||||
if abs > 10000000000000.0 || abs < 0.0000000000001 {
|
if abs > 10000000000000.0 || abs < 0.0000000000001 {
|
||||||
format!("{:e}", number).into()
|
format!("{:e}", number).into()
|
||||||
|
Loading…
Reference in New Issue
Block a user