我用C++ hypot()和做了一些测试Java Math.hypot.它们似乎都明显慢于sqrt(a*a + b*b).那是因为精度更高吗?计算斜边hypot函数的方法有哪些?令人惊讶的是,我在文档中找不到任何性能不佳的迹象.
我试图在ActionScript 3中编写一个公式,它将以度为单位给出var"z"(请参见下图),然后我将转换为弧度.
我已经知道了变量"x"和"y"的价值.使用三角函数,我如何计算斜边的长度,从而计算var z的可变角度?AS3或伪代码中的解决方案将非常有用.谢谢.

这是我在C中的第一个程序.当我运行它时,它发现的斜边是巨大的.我输入A和B作为2,输出为130899047838401965660347085857614698509581032940206478883553280.000000.我做错了什么?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int die(const char *msg);
double hypotenuse(double side0, double side1);
int main()
{
double a, b, c;
printf("Enter side A: ");
if (scanf_s("%1f", &a) != 1)
die("input failure");
printf("Enter side B: ");
if (scanf_s("%1f", &b) != 1)
die("input failure");
c = hypotenuse(a, b);
printf("The hypotenuse is %f\n ", c);
}
int die(const char *msg)
{
printf("Fatal Error: %s\n", msg);
exit(1);
}
double hypotenuse(double side0, double side1)
{
return sqrt((side0 * side0) + …Run Code Online (Sandbox Code Playgroud) 我针对标题中的问题编写了代码,似乎遇到了一些问题。谁能给我一些关于我做错了什么的见解或提示。尤其是代码的“if...else”部分。
这是问题#9。如果您单击该链接,它将显示问题的打印输出。 http://s21.postimg.org/nl2tmf5tj/Screen_Shot_2013_09_21_at_6_44_46_PM.png
这是我的代码:
import java.util.*;
public class Ch3Ex9 {
/**
* This method asks user for an x,y coordinates of a point, then returns the
* distance to the origin and which quadrant the point is in.
*/
public static void main(String[] args)
{
double xCoord; //x Coordinant initialized to 3
double yCoord; //y Coordinant initalized to 4
double hypo; //hypotenuse
//declare an instance of Scanner to read the datastream from the keyboard
Scanner keyboard = new Scanner(System.in);
//get …Run Code Online (Sandbox Code Playgroud)