Mój kod przekazuje kąt w radianach do cos
, tan
i sin
. Wszystko wydaje się działać dobrze, z wyjątkiem tan z 90
, co daje wartość 16331239353195370
z jakiegoś dziwnego powodu. Przykład Kod:tan() w języku Java zwracająca dziwną wartość
import java.text.DecimalFormat;
public class mathtable {
public static void main(String[] args) {
System.out.println("Angle Sin Cos Tan");
System.out.println("----- --- --- ---");
for (double angle = 0.0; angle < 180; angle +=5) {
double angle_rad = Math.toRadians(angle);
double sin = Math.sin(angle_rad);
String sin_4 = new DecimalFormat("#.####").format(sin);
double cos = Math.cos(angle_rad);
String cos_4 = new DecimalFormat("#.####").format(cos);
double tan = Math.tan(angle_rad);
String tan_4 = new DecimalFormat("#.####").format(tan);
System.out.println(angle + " " + sin_4 + " " + cos_4 + " " + tan_4);
}
}
}
co jest wartością nie powrócił ściśle równa IEEE nieskończoności?
Nie pi/4, ale pi/2 = 90 stopni. –
ahh tak, to ma sens, dziękuję! – Kynian
@SuzanCioc: Doh, dzięki, naprawione. –