Subject Re: [IBO] Problem with rounding .. any advice.
Author Martijn Tonies
Hello Adrian,

> I have the following situation:
>
> I enter a Cash value in an IB_Edit, then copy it to string.
> I then remove any spaces, R or $ signs
>
> code below:
> var
> PostEntry, TempTotal: Double;

What if you define this as Currency instead of Double? Cause you're putting
the Currency value ( ".AsCurrency" ) into a Double and expect no rounding?

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Sybase
SQL Anywhere, Oracle & MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com


> s: String;
> ....
> s:= IB_EditPayment.text; Here I enter 495.10
> delete(s,pos('R',s),1);
> delete(s,pos('r',s),1);
> delete(s,pos('$',s),1);
> while pos(' ',s)>0 do
> delete(s,pos(' ',s),1);
> TempPaymentStr := s;
>
> PostEntry := StrToFloat(TempPaymentStr); // PostEntry is
495.1
>
>
> I then retrieve TempEntry
> TempEntry := Prax.IB_QueryEntry.FieldByName('TransDebit').AsCurrency -
Prax.IB_QueryEntry.FieldByName('TransCredit').AsCurrency;
>
> TransDebit value contains 495.10
> TransCredit = 0.00 or can be null
>
> When comparing the two supposedly equal values:
> if PostEntry > TempTotal then
> ... it branches here, but both PostEntry, and TempTotal Contains 495.10
> else
> ... and should thus branch here.
>
> This must be some floating point thingy with 495.10000000000000003456 or
something like that, throwing me.
>
> How do I circumvent this behaviour.
>
> PS TransCredit and TransDebit defined as Numeric(15.2) ODS 11.1
FB2.1.1.17910-0
>
>
> [Non-text portions of this message have been removed]
>
>
> ------------------------------------
>
>
___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or
InterBase
> without the need for BDE, ODBC or any other layer.
>
___________________________________________________________________________
> http://www.ibobjects.com - your IBO community resource for Tech Info
papers,
> keyword-searchable FAQ, community code contributions and more !
Yahoo! Groups Links
>
>
>