Math ugliness.

J

Jorge

In comp.lang.javascript message <55724004-b075-48be-a9f8-bd1d01e2374e@z1
9g2000yqk.googlegroups.com>, Tue, 16 Feb 2010 15:23:12, Jorge
<[email protected]> posted:





Maybe useful for legibility, which means an aid to coding the desired
algorithm.  OTOH, is it better than enclosing maths as
        with (Math) { ... }     // ?

Expected modest loss in performance, which only matters in those
relatively few cases where JavaScript maths is neither inconveniently
slow nor unnecessarily fast.

For those who want legibility and speed, you could write code to
translate "your" maths to/from the standard form.

Your eventual examples need to show how to get, for example, the sine of
an expression; and to warn that 3.sin() is not the same as 3.0.sin().
Those will not be instantly and certainly obvious to all.

Yep. I think in general Number literals ought to be enclosed in
parens. And some math methods could be getters, but I wonder whether
(12345).rnd.floor is any clearer than (12345).rnd().floor(). Some
other methods, as e.g. "pow", could not, as they require a parameter.
How about writing a Reverse Polish Notation interpreter in JavaScript,
to suggest that RPN may one day be included in the language proper?  My
LONGCALC.EXE reads, and uses, RPN.

You'd need a stack for that, and an "enter" operator, and roll down,
x<->y etc. stack handling operators. Oh, how far away are the days
with my hp65... the 100 steps, the 10 memories, the 5 labels, those
magnetic cards, the beautiful led display, DSP.2 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top