Hi Jabier,
  I'm not 100% sure, but you may consider to always use floating point numbers for the type of calculation you are doing, unless you are sure you want integer calculation. So then it becomes:
(4./3.) * (sqrt(2.) - 1.)
regards,
  Johan


On 1-7-2014 9:41, Jabiertxo Arraiza Cenoz wrote:
Thanks Nathan. I just read it in a book but dont remeber when
necessary :(.
And thanks for the operator precedence tip.

Cheers, Jabier.


El mar, 01-07-2014 a las 07:59 +1000, Nathan Hurst escribió:
On Mon, Jun 30, 2014 at 11:56:15PM +0200, Jabiertxo Arraiza Cenoz wrote:
Hi to all.

I try this in my debian calculator:
"4 / 3 * (sqrt(2) - 1)" and return 0,55228475
in C++ return 0.414214

I want 0,55228475.
Where i lost? I have the cmath header
4/3 = 1 because the type of both arguments is int. 4.0/3 fixes your
problem.  I would put (4./3) * sqrt() because operator precedence for
divide is not always clear.

njh

      

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft


_______________________________________________
Inkscape-devel mailing list
Inkscape-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/inkscape-devel