Skip to content

Conversation

@ITZ-NIHALPATEL
Copy link

This pull request introduces a new Fortran module for calculating square roots and a dedicated test program to validate its functionality. The changes provide a reusable function for square root calculation, including error handling for negative inputs, and comprehensive test coverage with multiple scenarios.

New square root functionality:

  • Added square_root_module containing the calculate_sqrt function, which computes the square root of a non-negative number using Fortran's intrinsic SQRT function and returns -1.0 for negative inputs.

Test coverage:

  • Created tests_square_root.f90 program with six test cases covering zero, one, perfect squares, non-perfect squares, large numbers, and negative input scenarios for the square root function.
  • Implemented assert_test subroutine for floating-point comparison with tolerance, providing clear pass/fail output and stopping execution on test failure.

This module provides a function to calculate the square root of a number using Fortran's intrinsic SQRT function. It includes error handling for negative input.
This program provides test cases to validate the square root function in the square_root_module, including tests for zero, one, perfect squares, non-perfect squares, large numbers, and negative input.
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