• Welcome, Guest. Please login.
 
May 26, 2019, 12:37:18 pm

News:

Welcome to the SQLitening support forums!


Price of 0,89 divide by 1.19 = 0 ?

Started by sqltyp, June 07, 2013, 12:46:48 pm

Previous topic - Next topic

sqltyp



I don't understand why the resault is 0 when I devide by 1.19
I think the resault should be 0,75




Maybe someone can help?  ::)

Rolf Brandt

Looks like this happens only with values that are smaller than 1,00
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

cj

Please show source code.

FUNCTION PBMAIN () AS LONG
    ? STR$(89/1.19) '74.789912370157
END FUNCTION 

sqltyp

June 08, 2013, 06:46:45 am #3 Last Edit: June 08, 2013, 06:49:31 am by sqltyp
Hi, the program is sqllite (firefox addon):
http://en.wikipedia.org/wiki/SQLite


[code]Select Kunden.Firmenname, Artikel.ArtikelID, Artikel.Bezeichnung, Artikel.Preis as BruttoPreis, round(Artikel.Preis/1.19,2) as netto, Artikel.Preis * 0.19 as MWST
from Artikel, Kunden, Auftr

Rolf Brandt

June 08, 2013, 08:08:55 am #4 Last Edit: June 08, 2013, 08:30:04 am by Rolf Brandt
It seems that the problem occurs whith values < 1,0 and if you use the comma for decimal separation. If you use the dot for separation SQLite will give you the desired result.
(See picture done with SQLiteExpert)

Problem: SQLite will handle a value with a leading "0" followed by a comma as a string and not as a numeric variable.
Solution: Always use "." as decimal separator. (The comma "," is usually used as 1000-separator in English (1,000,000,25). This is exactly contrary to the German use.)

See also here:
http://www.sqlite.org/datatype3.html

Rolf
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

sqltyp

@Rolf Brandt

Ah. Right. That was the mistake. Thank you very much.  ;D

cj

Thank you, Rolf.
As a note:  1,000,000,25 should be 100,000,025

Rolf Brandt

I had really meant '100,000.25' which in Germany would be '1000.000,25'.
Tricky sometimes, I often fall into that trap.

Rolf
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu