Re: Why Java's math expression (power) is so inconvenient and error prone?



Lionel wrote:
My program need a lot of calculation of power. In many programming
languages,

2**3 = 8;

The syntax is clean and easy. But in Java,

Math.pow(2, 3) = 8; //It is so long, and complicated and error prone

Again, in many languages,

EXP(1) = 2.7 //e value

But in Java,

Math.pow(Math.E, 1) = 2.7 //You see, so complicated

Error prone? All the above answers look correct. Can you tell us how it is error prone?

I agree with that.

It looks like you have come from C and are expecting non-object-oriented code. Simple, get over it.

Actually C is very similar to Java. C does not have an
exponentation operator like Fortran and VB.

If that is still too difficult I suggestion you learn about the advantages of an Object-Oriented programming language.

Hm.

I would not consider the Math static methods so fantastic
object oriented ...

Arne
.



Relevant Pages

  • Re: Basic inheritance question
    ... used 'this' in C++ and Java. ... but in Python it doesn't. ... you meant "in languages that has implicit instance reference available in methods"? ...
    (comp.lang.python)
  • Re: Looking for programming examples in any programming language
    ... in an in-page applet. ... do that for such a broad range of languages. ... But note even Java applets ... If you're going to separate the specific I/O environment from ...
    (comp.programming)
  • Re: parser
    ... and by no means is Java some obscure language... ... but I still feel that both C and C++ are good languages to use for ... leaving the backend interpreter/JIT as a simpler piece of machinery). ... that you believe that C lacks the ability to build parsers as masses of tiny ...
    (comp.programming)
  • Re: OO compilers and efficiency
    ... > will be difficult for a compiler to do a good job of spotting when the OO ... "simpler" languages, ... I agree that Java ... (including adding lexical closures) ...
    (comp.programming)
  • Re: Basic inheritance question
    ... Old Java habits die slowly. ... No, seriously it isn't Java habits only, most other languages wouldn't ... That's not very far from what a Python method object does - ... reference to the current instance is to pass it as an argument to the ...
    (comp.lang.python)