🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: be.comp.programming
2 messages
2 total messages Started by jan bruggeman Wed, 19 Feb 2003 21:59
Kan java rekenen ?
#5942
Author: jan bruggeman
Date: Wed, 19 Feb 2003 21:59
40 lines
2306 bytes
Beste,

Bij mij geeft volgend java programma:

import java.lang.Math;
public class Test {
        public static void main(String[] args) {
                System.out.println("Sinus of 00 = " + Math.sin(0d));
                System.out.println("Sinus of 30 = " + Math.sin(30d));
                System.out.println("Sinus of 60 = " + Math.sin(60d));
                System.out.println("Sinus of 90 = " + Math.sin(90d));
                System.out.println("Cos of 00 = " + Math.cos(0d));
                System.out.println("Cos of 30 = " + Math.cos(30d));
                System.out.println("Cos of 60 = " + Math.cos(60d));
                System.out.println("Cos of 90 = " + Math.cos(90d));
        }
}

volgende output:

[root@cook javaprog]# java Test
Sinus of 00 = 0.0
Sinus of 30 = -0.9880316240928618
Sinus of 60 = -0.3048106211022167
Sinus of 90 = 0.8939966636005579
Cos of 00 = 1.0
Cos of 30 = 0.15425144988758405
Cos of 60 = -0.9524129804151563
Cos of 90 = -0.4480736161291701

Er zijn veel rekenmachine's die daar anders over denken ... Where's the 
catch ?

nb: Ik probeerde het ook met door de waarden als 30.0e0 te schrijven, of 
door eerst een variabele van het type double te definieren en die te 
gebruiken in de berekening, altijd hetzelfde.

-- 
Jan Bruggeman
reply to: jan dot bruggeman at advalvas dot be
Re: Kan java rekenen ?
#5943
Author: Haplo
Date: Wed, 19 Feb 2003 22:16
44 lines
2663 bytes
In article <3e53fd7c$0$23366$afc38c87@sisyphus.news.be.easynet.net>, 
ikke@hier.be says...
> Beste,
> 
> Bij mij geeft volgend java programma:
> 
> import java.lang.Math;
> public class Test {
>         public static void main(String[] args) {
>                 System.out.println("Sinus of 00 = " + Math.sin(0d));
>                 System.out.println("Sinus of 30 = " + Math.sin(30d));
>                 System.out.println("Sinus of 60 = " + Math.sin(60d));
>                 System.out.println("Sinus of 90 = " + Math.sin(90d));
>                 System.out.println("Cos of 00 = " + Math.cos(0d));
>                 System.out.println("Cos of 30 = " + Math.cos(30d));
>                 System.out.println("Cos of 60 = " + Math.cos(60d));
>                 System.out.println("Cos of 90 = " + Math.cos(90d));
>         }
> }
> 
> volgende output:
> 
> [root@cook javaprog]# java Test
> Sinus of 00 = 0.0
> Sinus of 30 = -0.9880316240928618
> Sinus of 60 = -0.3048106211022167
> Sinus of 90 = 0.8939966636005579
> Cos of 00 = 1.0
> Cos of 30 = 0.15425144988758405
> Cos of 60 = -0.9524129804151563
> Cos of 90 = -0.4480736161291701
> 
> Er zijn veel rekenmachine's die daar anders over denken ... Where's the 
> catch ?
> 
> nb: Ik probeerde het ook met door de waarden als 30.0e0 te schrijven, of 
> door eerst een variabele van het type double te definieren en die te 
> gebruiken in de berekening, altijd hetzelfde.

Math.sin en Math.cos hebben een waarde in radialen als input parameter. 
Dus niet in graden. Je zult je waarden eerst naar radialen moeten 
omzetten met Math.toRadians.

Haplo
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads