HYPOT: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 20: | Line 20: | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|DIM}} leg_x {{Cl|AS}} {{Cl|DOUBLE}}, leg_y {{Cl|AS}} {{Cl|DOUBLE}}, result {{Cl|AS}} {{Cl|DOUBLE}} | {{Cl|DIM}} leg_x {{Cl|AS}} {{Cl|DOUBLE}}, leg_y {{Cl|AS}} {{Cl|DOUBLE}}, result {{Cl|AS}} {{Cl|DOUBLE}} | ||
leg_x = 3 | leg_x = {{Text|3|#F580B1}} | ||
leg_y = 4 | leg_y = {{Text|4|#F580B1}} | ||
result = {{Cl|_HYPOT}}(leg_x, leg_y) | result = {{Cl|_HYPOT}}(leg_x, leg_y) | ||
{{Cl|PRINT USING}} "## , ## and ## form a right-angled triangle."; leg_x; leg_y; result | {{Cl|PRINT USING}} {{Text|<nowiki>"## , ## and ## form a right-angled triangle."</nowiki>|#FFB100}}; leg_x; leg_y; result | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{OutputStart}} | {{OutputStart}} | ||
3 , 4 and 5 form a right-angled triangle. | 3 , 4 and 5 form a right-angled triangle. | ||
Line 32: | Line 31: | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [https://qb64phoenix.com/forum/showthread.php?tid=1782 Featured in our "Keyword of the Day" series] | |||
* [[ATN]] {{Text|(arctangent)}} | * [[ATN]] {{Text|(arctangent)}} | ||
* [[_PI]] {{Text|(function)}} | * [[_PI]] {{Text|(function)}} |
Latest revision as of 22:33, 25 May 2024
The _HYPOT function returns the hypotenuse of a right-angled triangle whose legs are x and y.
Syntax
- result! = _HYPOT(x, y)
Parameters
- x and y are the floating point values corresponding to the legs of a right-angled (90 degree) triangle for which the hypotenuse is computed.
Description
- The function returns what would be the square root of the sum of the squares of x and y (as per the Pythagorean theorem).
- The hypotenuse is the longest side between the two 90 degree angle sides
Examples
Example:
DIM leg_x AS DOUBLE, leg_y AS DOUBLE, result AS DOUBLE leg_x = 3 leg_y = 4 result = _HYPOT(leg_x, leg_y) PRINT USING "## , ## and ## form a right-angled triangle."; leg_x; leg_y; result |
3 , 4 and 5 form a right-angled triangle. |
See also
- Featured in our "Keyword of the Day" series
- ATN (arctangent)
- _PI (function)
- Mathematical Operations
- C++ reference for hypot() - source of the text and sample above