| Newsgroups |
gmane.comp.windows.gui4cli |
| Message-ID |
<[email protected]> |
Hi,
The expression evaluation uses 'sprintf (out, "%f", res))' at the end and the default precision is 6 digits for %f.
I think the best solution would be to add a SET FLOAT witdh.precision statement by Dimitris with default .6 to keep compability.
Another solution would be to make a math dll, i can try to use the same module G4C uses for math in a dll with a greather precision.
It can take a while since i have a cold and yesterday had 39,3 degrees so i don't think very fast :)
I already did make the eval module as a command line tool so it should not be to difficult.
Using bc you would have a high precision calculator as long as you use only strings and no calculation in G4C.
Regards,
Fred.
--- In [email protected], dazroo <daz4roo@...> wrote:
>
> Apologies to group for one of those "scattered" replies.
>
> On 18/09/10 00:02, Marianne wrote:
> >
> >
> >
> >
> > Hi Daz and Mike
> >
> > Thanks for the response but BC will not help me. I apologise if my
> > knowledge is not up to date or standard.
> >
> > I am using Gui4Cli currently for all calculations as I can perform all
> > calculations in Gui4Cli.
>
> Floating Point Arithmetic (FPA) is notoriously error-prone in many computer
> implementations. Here's one explanation:
> http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
>
>
> > Secondly I am a self studied programmer and do
> > not know a lot about programming. I only know a little Basic. Here is an
> > example and if I am off target please let me know.
> >
> > Take the following example:
> > A = 1
> > B = 1.538
> >
> > So A/B = 0.649772579597141...... and I want to round this off say to 8
> > decimals. I cannot do the following:
>
> That result is already inaccurate (before rounding) :(
>
> Copy/Paste the following into the bottom box at:
> http://sciencesoft.at/bc/?lang=en
> --------------------------------------------
> a = 1
> b = 1.538
> g4cans = 0.649772579597141
> a/b
> a/b - g4cans
> --------------------------------------------
> and click "Calculate"
>
> Result:
> .65019505851755526657 .00042247892041426657
>
> That's a g4c inaccuracy of .00042247892041426657 on that one
> calculation.
>
> ( I get the answer of around .65019506 in three other programs. )
>
>
> >
> > C = $($A/$B) = 0.649773 and send C to the external program, say BC,
> > because Gui4Cli already rounded $C to 6 decimals. I can probably send
> > $A/$B to BC (not tested yet as calculations are sometimes lenghty in
> > statisics and not that easy to do it this way, if possible. (Will not be
> > possible if one uses loops for example.)
> >
>
> I would recommend staying away from the in-built FPA and, instead,
> call an external program (designed for the task) via [DOS.DLL] passing
> FP-like numbers as strings.
> Once your FP calculations are done and rounded, then you can
> present the results in your gui as strings in the precision required.
>
> > In other words it seems to me that all calculations therefore have to be
> > performed with an external program if you want rounding off to more than
> > 6 decimals. Although Gui stands for Graphical User Interface that is not
> > what I want. (The majority of other languages do have a Gui interface,
> > but I like Gui4Cli because of its simplicity.
>
> FP = major complexity :) - no fault of Gui4Cli.
> Use Gui4Cli with a reliably accurate external library routines for FPA.
>
> >
> > Why do I need so many decimals? This is to perform for example
> > convergence problems of Functions, like probabilities and one will be
> > suprised how quick Gui4Cli is.(My standards)
> >
> > If Gui4Cli can give decimals to more than 6 or if a new command such as
> > 'Set Decimals to $value' can be added it will be great but I do not know
> > how easy or difficult it will be.
>
> It would be a daunting task, I think.
> Take your example which I gave to BC:
> What value would more decimal places on the end of an already
> inaccurate result be? ;)
>
> In other scripting language forums, I've seen strong
> recommendations for avoiding doing currency calculations
> in FPA (e.g. 7.55eur). Instead, they suggest do all calculations
> in cents (755c) because you can't get unexpected rounding
> anomalies using integer arithmetic (only programming bugs).
>
> >
> > Regards
> >
> > Frans
> >
>
> To you, also.
>
> daz
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/gui4cli/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/gui4cli/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/