Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Operation in String to Double conversion

Reply
Thread Tools

Operation in String to Double conversion

 
 
frank.asseg@gmail.com
Guest
Posts: n/a
 
      10-15-2012
On Monday, October 15, 2012 9:40:04 PM UTC+2, Lew wrote:
> If you cannot even promote a product with professionalism and attention to
> detail, it is very unlikely the product will reflect a higher standard.

again i beg to differ. the code quality has got nothing to do with the manner an article about the library is written. i think judging a developer's skill based on his professionalism as an editor is like saying a monkey can't climb because he sucks at flying.

> He already gave you constructive criticism and you acted like a jerk about it.

well i certainly didn't call him a jerk for having a different opinion. so in order not to succumb to godwin's law i won't respond to any more posts regarding the manner in which i choose to write.


 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      10-15-2012
(E-Mail Removed) wrote:
>Lew wrote:
>> If you cannot even promote a product with professionalism and attention to
>> detail, it is very unlikely the product will reflect a higher standard.

>
> again i [sic] beg to differ. the code quality has got nothing to do with the manner an article about the
> library is written. i think judging a developer's skill based on his professionalism as an editor is like
> saying a monkey can't climb because he sucks at flying.


You can make up all the cute similes you like, but my experience is solid in this area.

Illiterate descriptions rarely correspond to quality products.

>> He already gave you constructive criticism and you acted like a jerk about it.

>
> well i [sic] certainly didn't call him a jerk for having a different opinion.
> so in order not to succumb to godwin's law i [sic] won't respond to any more posts regarding the
> manner in which i [sic] choose to write.


Good luck with that attitude. You'll need it.

And you not calling him a jerk didn't mean you didn't act like one. Your whole attitude is
resentful and hostile despite being given good advice.

No one but you cares about your ego.

--
Lew

 
Reply With Quote
 
 
 
 
Arved Sandstrom
Guest
Posts: n/a
 
      10-15-2012
On 10/15/2012 06:24 PM, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> On Monday, October 15, 2012 9:40:04 PM UTC+2, Lew wrote:
>> If you cannot even promote a product with professionalism and attention to
>> detail, it is very unlikely the product will reflect a higher standard.

> again i beg to differ. the code quality has got nothing to do with the manner an article about the library is written. i think judging a developer's skill based on his professionalism as an editor is like saying a monkey can't climb because he sucks at flying.
>
>> He already gave you constructive criticism and you acted like a jerk about it.

> well i certainly didn't call him a jerk for having a different opinion. so in order not to succumb to godwin's law i won't respond to any more posts regarding the manner in which i choose to write.
>
>

The way I see it, the project page is fine. The article does have
grammar and spelling problems to the extent that I also, like Lew,
started to question the code...*until* I noticed that the author
(yourself) is from SW Germany.

This is one of the first things I do when I see that software
documentation and/or related writings have grammar and spelling problems
- I check to see if English is the author's first language.

AHS
 
Reply With Quote
 
Daniele Futtorovic
Guest
Posts: n/a
 
      10-15-2012
On 15/10/2012 20:18, (E-Mail Removed) allegedly wrote:
>> I don't think I much care for that site you link too. Too many spelling
>> mistakes ("i" and "java") for me to take it seriously.

> wow, sorry for not complying with your orthographical requirements, although imho that's hardly grounds to disregard the library.
> maybe this site is more to your liking:
> http://www.objecthunter.net/exp4j/
> although there are probably some typos in there too
> the lib may not be perfect, and i'm sure there are things that can be done to optimize the implementation, changes i'd be happy to adapt. so take a look at the github project and drop me a line if you have some constructive criticism regarding the implementation.


You are the author that lib, right? Then allow me, for what it is worth,
to opine with markspace -- not only, incidentally, with his opinion, but
more importantly and fundamentally, with his approach.

/Le style, c'est l'homme/, as the saying goes. Style matters. Not so
much in and of itself, but to the extent of what it tells you about the
author. It doesn't tell you everything, and it is not always right, but
it is so more often than not. And most importantly, it allows you to
come to an at least preliminary conclusion in the face of a limited set
of data.

Being able to make quick decisions is a crucial skill, as I am sure
you'll realise, or would after giving it minimal thought. You need means
to separate the wheat from the chaff -- the quicker you are able to do
this, the more productive you can be. When choosing a library, you
rarely have the luxury of analysing it in every last detail. Especially
if it performs a fairly common, and merely cumbersome, task, picking it
apart might take longer than just writing the damn thing yourself.

In such a situation, you need to discriminate effectively; you need
effective discriminators. Good-will and trust -- say, if it's a library
published by someone whose other works you've used to your satisfaction
-- can be one such discriminator, and perhaps the most important one.
Failing that, or in conjunction with that, apparent style (code style,
but also, as they're related, lexical and overall style) is perhaps the
second most important one.

That being said, your grammar and, if you'll pardon my saying so, the
slight snottiness you display here notwithstanding, the code examples on
your page look fairly okay, and if I were the OP, and didn't have the
alternative of using the scripting engine (or if my task required
functions and the other more advanced features you offer), I'd probably
give your lib a good second look.

My two cents. Please don't flame me.

--
DF.
 
Reply With Quote
 
frank.asseg@gmail.com
Guest
Posts: n/a
 
      10-15-2012
On Tuesday, October 16, 2012 12:14:36 AM UTC+2, Daniele Futtorovic wrote:


> [...] and if I were the OP, and didn't have the
> alternative of using the scripting engine (or if my task required
> functions and the other more advanced features you offer), I'd probably
> give your lib a good second look.

the jsr223 scripting engine works fine, but is rather slow, this is the comparison with pure java math, livetribe's jsr223 implementation and exp4j from the tests on my local desktop machine:

expression log(x) - y * (sqrt(x^cos(y)))
exp4j 1123189 [561.59k calc/sec]
Java Math 4590231 [2295.12k calc/sec]
JSR 223(Javascript) 1674 [837.0 calc/sec]

This of course is a very synthetic benchmark, but be aware that the scripting engine can be quite slow when performing a lot of operations, and a lot of performance is to be gained with a pure java implementation. and this argument does neither include the time to warm up the script engine nor the increased memory footprint.
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      10-16-2012
On 10/14/2012 3:39 PM, William Lopes wrote:
> Hi guys!
>
> So, I have to do a conversion between String and Double object, but my string is a mathematical operation like "100 + 10". Even when I make a conversion using NumberFormat.getInstance of "100 + 10", my result is 100.0 only.
>
> I would like to do it without split my string of way manually.


I wrote an expression evaluator will accept such a string and
produce an object instance that can then be evaluated:

Expression e = Expression.compile("100 + 10", null);
double value = e.value(null);

More generally,

// Formula for volume of a cylinder:
Expression e = Expression.compile(
"(diameter/2)^2 * PI * height",
new String[] { "diameter", "height" });

// Volume of a cylinder of diameter 4, height 10:
double volume = e.value(new double[] { 4.0, 10.0 });

The only unusual feature is that expressions compile directly to
Java byte code rather than to an interpreted pseudo-code; their
value() methods can therefore be JITted for speedier execution.
This is surely overkill for your problem (and for many others;
it was an over-engineered learning exercise), but should solve it
nonetheless. Internally, though, the compiler splits the string
"of my way manually," which you seem to find distasteful. Sue me.

Send an E-mail address if you'd like a copy. No warranties.

--
Eric Sosman
(E-Mail Removed)d
 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      10-16-2012
In article <3PZes.19616$(E-Mail Removed)>,
Daniel Pitts <(E-Mail Removed)> wrote:

> On 10/15/12 10:19 AM, John B. Matthews wrote:
> > In article <(E-Mail Removed)>,
> > William Lopes <(E-Mail Removed)> wrote:
> >
> >> I have to do a conversion between String and Double object, but my
> >> string is a mathematical operation like "100 + 10". Even when I
> >> make a conversion using NumberFormat.getInstance of "100 + 10", my
> >> result is 100.0 only.
> >>
> >> I would like to do it without split my string of way manually.

> >
> > Your distribution may already contain a suitable implementation of
> > javax.script.ScriptEngine:
> >
> > ScriptEngineManager mgr = new ScriptEngineManager();
> > List<ScriptEngineFactory> factories = mgr.getEngineFactories();
> > for (ScriptEngineFactory f : factories) {
> > System.out.println(f);
> > }
> >
> > Selecting the available RhinoScriptEngine by extension
> >
> > ScriptEngine engine = mgr.getEngineByExtension("js");
> > try {
> > System.out.println(engine.eval("5 * 8 + 2"));
> > } catch (ScriptException ex) {
> > ex.printStackTrace(System.err);
> > }
> >
> > prints the expected answer, 42.0.
> >

> Another library I tend to favor is OGNL, it will solve your problem
> specifically, and is much more powerful.


Cited for a tantalizing suggestion regarding TableModel and an important
tip on pronunciation.

<http://commons.apache.org/ognl/>

> It *is* a programming language in its own rite, so use with caution
> (eg, only strings you from trusted sources).


This bears repeating; it also applies to the RhinoScriptEngine, et al.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
Arne Vajhoej
Guest
Posts: n/a
 
      10-17-2012
On 10/14/2012 3:39 PM, William Lopes wrote:
> So, I have to do a conversion between String and Double object, but
> my string is a mathematical operation like "100 + 10". Even when I
> make a conversion using NumberFormat.getInstance of "100 + 10", my
> result is 100.0 only.
>
> I would like to do it without split my string of way manually.


Many options:
* Write an expression evaluator from scratch
* Write an expression evaluator using a parser generator
* Generate Java code, compile it, load it and call it
* Call a script engine (JavaScript, BeanShell etc.)

Unless performance is critical I would go for BeanShell. Any
Java developer should know the syntax and it is relative easy
to call.

Arne



 
Reply With Quote
 
Arne Vajhoej
Guest
Posts: n/a
 
      10-17-2012
On 10/15/2012 6:14 PM, Arved Sandstrom wrote:
> On 10/15/2012 06:24 PM, (E-Mail Removed) wrote:
>> On Monday, October 15, 2012 9:40:04 PM UTC+2, Lew wrote:
>>> If you cannot even promote a product with professionalism and
>>> attention to
>>> detail, it is very unlikely the product will reflect a higher standard.

>> again i beg to differ. the code quality has got nothing to do with the
>> manner an article about the library is written. i think judging a
>> developer's skill based on his professionalism as an editor is like
>> saying a monkey can't climb because he sucks at flying.
>>
>>> He already gave you constructive criticism and you acted like a jerk
>>> about it.

>> well i certainly didn't call him a jerk for having a different
>> opinion. so in order not to succumb to godwin's law i won't respond to
>> any more posts regarding the manner in which i choose to write.
>>
>>

> The way I see it, the project page is fine. The article does have
> grammar and spelling problems to the extent that I also, like Lew,
> started to question the code...*until* I noticed that the author
> (yourself) is from SW Germany.
>
> This is one of the first things I do when I see that software
> documentation and/or related writings have grammar and spelling problems
> - I check to see if English is the author's first language.


In general I agree.

But "java" does not look good in German either.

Arne


 
Reply With Quote
 
Arne Vajhoej
Guest
Posts: n/a
 
      10-17-2012
On 10/15/2012 5:24 PM, (E-Mail Removed) wrote:
> On Monday, October 15, 2012 9:40:04 PM UTC+2, Lew wrote:
>> He already gave you constructive criticism and you acted like a
>> jerk about it.

> well i certainly didn't call him a jerk for having a different
> opinion.


You got criticism and you replied with sarcastic comments.

So you demonstrated that you are not willing to listen to
criticism and attack those that provide such.

Arne


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cast operation or string conversion? Giuseppe:G: C++ 7 07-12-2008 12:09 AM
I/O operation, file operation behaviou raan C++ 2 08-16-2007 07:13 PM
conversion double* to vector<double> and vice versa J.M. C++ 5 03-08-2007 03:45 PM
Does bit operation always work more efficiently than math operation? david ullua C Programming 13 03-01-2006 11:02 PM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM



Advertisments