[Gambas-user] Custom library function returns wrong value

Fabien Bodard gambas.fr at ...626...
Thu Feb 5 14:23:56 CET 2015


And if you do only :

Cint(Replace(sValue,".",""))


This would avoid float round errors

2015-02-05 12:13 GMT+01:00 bill-lancaster <bill-lancaster at ...2231...>:
> I have a Procedure in MyLib to convert a 'money' string to integer value.
>
> Static Public Procedure StrMoneyToInt(sVal As String) As Integer
> Dim f As Float
>      f = Val(sVal)
>      Return f * 100
> End
>
> Some values are incorrectly returned.  For example:-
>
> This code calls the procedure
>
> Dim sMoney As String
>      sMoney = "38.37"
>      f = Val(sMoney)
>      Print f;; f * 100;; MyLib.StrMoneyToInt(sMoney)
> Gives:-
> 38.37 3837 3836
>
> Any ideas?
>
> Gambas3.5.3
>
>
>
> --
> View this message in context: http://gambas.8142.n7.nabble.com/Custom-library-function-returns-wrong-value-tp50542.html
> Sent from the gambas-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard




More information about the User mailing list