Skip to content

Conversation

@BrianHung
Copy link
Owner

Summary

  • add EVEN and ODD math functions
  • document them as implemented
  • expose the functions via the function registry
  • test EVEN and ODD behaviour

Testing

  • cargo test --no-fail-fast --quiet

https://chatgpt.com/codex/tasks/task_e_688a6d7a13388327ae536d837aa9750f

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugbot free trial expires on August 2, 2025
Learn more in the Cursor dashboard.

n += if f >= 0.0 { 1.0 } else { -1.0 };
}
Ok(n)
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Floating Point to Integer Overflow in Modulo Functions

The EVEN and ODD functions can panic or produce incorrect results due to unsafe f64 to i64 casting for modulo operations. For very large negative numbers (including negative infinity), (n as i64).abs() can overflow, causing a panic in debug mode. For very large positive numbers exceeding i64::MAX, the f64 to i64 cast itself overflows, leading to undefined behavior and incorrect modulo calculations.

Fix in Cursor Fix in Web

@BrianHung BrianHung changed the title Implement EVEN and ODD functions even, odd Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants