ViMeAv ICT Member Licensed User Longtime User Jun 30, 2017 #1 Dim nVal As Long Dim nPrice As Double nPrice = 8.95 nVal = nPrice * 100 nVal returns 894. How is this possible? If I use 2.95, it's okay. (or all other numbers I have tested until now)
Dim nVal As Long Dim nPrice As Double nPrice = 8.95 nVal = nPrice * 100 nVal returns 894. How is this possible? If I use 2.95, it's okay. (or all other numbers I have tested until now)
Star-Dust Expert Licensed User Longtime User Jun 30, 2017 #2 I've been through it many times. In a accounting calculation program I realized I had many problems for this error. Now I pass the double in the string and shift the decimal decimal point with the string to not have any calculation errors. Upvote 0
I've been through it many times. In a accounting calculation program I realized I had many problems for this error. Now I pass the double in the string and shift the decimal decimal point with the string to not have any calculation errors.
Star-Dust Expert Licensed User Longtime User Jun 30, 2017 #3 B4X: Dim nVal As Long Dim nPrice As Double Dim S as string nPrice = 8.95 S=nPrice nVal = S.Replace(".","") Upvote 0
B4X: Dim nVal As Long Dim nPrice As Double Dim S as string nPrice = 8.95 S=nPrice nVal = S.Replace(".","")
Informatix Expert Licensed User Longtime User Jun 30, 2017 #4 ViMeAv ICT said: Dim nVal As Long Dim nPrice As Double nPrice = 8.95 nVal = nPrice * 100 nVal returns 894. How is this possible? If I use 2.95, it's okay. (or all other numbers I have tested until now) Click to expand... In our apps where we have money amounts, float values are used only for display. Everything is stored and computed as integers (or longs). e.g. 1.37 (display) = 137 (integer) Upvote 0
ViMeAv ICT said: Dim nVal As Long Dim nPrice As Double nPrice = 8.95 nVal = nPrice * 100 nVal returns 894. How is this possible? If I use 2.95, it's okay. (or all other numbers I have tested until now) Click to expand... In our apps where we have money amounts, float values are used only for display. Everything is stored and computed as integers (or longs). e.g. 1.37 (display) = 137 (integer)
Star-Dust Expert Licensed User Longtime User Jun 30, 2017 #5 Yes, but I understand it too late.. Upvote 0
ViMeAv ICT Member Licensed User Longtime User Jul 6, 2017 #6 Thaks for all the answers, it helped me out. Upvote 0