Skip to content

Refactor iszero() and isnan() to accept all numeric types #20089

Description

@Jefffrey

Is your feature request related to a problem or challenge?

Currently iszero() and isnan() coerce inputs to float to compute:

pub fn new() -> Self {
// Accept any numeric type and coerce to float
let float = Coercion::new_implicit(
TypeSignatureClass::Float,
vec![TypeSignatureClass::Numeric],
NativeType::Float64,
);
Self {
signature: Signature::coercible(vec![float], Volatility::Immutable),
}
}

pub fn new() -> Self {
// Accept any numeric type and coerce to float
let float = Coercion::new_implicit(
TypeSignatureClass::Float,
vec![TypeSignatureClass::Numeric],
NativeType::Float64,
);
Self {
signature: Signature::coercible(vec![float], Volatility::Immutable),
}
}

Describe the solution you'd like

Consider refactoring these to accept numeric types without coercing to float; the implementations should be simple (albeit verbose/tedious). For example, isnan() should return false for any numeric inputs that aren't float type, which might be a slight optimization.

Describe alternatives you've considered

If we prefer to keep the code simple we can leave it as is

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions