Skip to content

Create RocketGuidanceSystem.java#5

Open
vivek-kumar-2024 wants to merge 1 commit intomainfrom
vivek-kumar-2024-patch-5
Open

Create RocketGuidanceSystem.java#5
vivek-kumar-2024 wants to merge 1 commit intomainfrom
vivek-kumar-2024-patch-5

Conversation

@vivek-kumar-2024
Copy link
Owner

No description provided.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR adds the RocketGuidanceSystem.java file implementing a new processVelocity method with velocity conversion and error handling logic.

  • Added /RocketGuidanceSystem.java to perform casting from double to short.
  • Includes a check for negative values that can be falsely triggered due to overflow.
  • Uses basic exception handling to signal issues in the guidance process.
  • The core guidance logic is left as a stub for future enhancements.

1 file reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

@@ -0,0 +1,17 @@
public class RocketGuidanceSystem {
public static void processVelocity(double horizontalVelocity) {
short velocityData = (short) horizontalVelocity;
Copy link

Choose a reason for hiding this comment

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

logic: Casting from double to short can overflow; if horizontalVelocity > 32767, it becomes negative.

Suggested change
short velocityData = (short) horizontalVelocity;
if (horizontalVelocity > Short.MAX_VALUE || horizontalVelocity < Short.MIN_VALUE) {
throw new IllegalArgumentException("Velocity value out of range for short: " + horizontalVelocity);
}
short velocityData = (short) horizontalVelocity;

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant