Einzelnen Beitrag anzeigen

Benutzerbild von MyRealName
MyRealName

Registriert seit: 19. Okt 2003
Ort: Heilbronn
673 Beiträge
 
Delphi 10.4 Sydney
 
#6

AW: Firebird und Numeric fields

  Alt 21. Jul 2017, 19:38
Eigentlich wollte ich ja numeric(18.4) für alle Currency-Felder, aber jede mathematische Op in firebird erzeugt daraus ein 18,8...

bei mir nicht.. welche Firebirdversion hast Du denn? Die 2.1 macht das problemlos mit:



Code:
CREATE TABLE Test (
test1 Numeric(18,4),
test2 Numeric(18,4),
test3 Numeric(18,4));


INSERT INTO test VALUES (2.5, 5, 0);

UPDATE test SET test3=Test1*test2;
Und selbst wenn das in neueren Firebird geändert wurde, was spricht denn gegen ein

Code:
Select cast(test1*test2 AS Numeric(18.4)) from test
Grüße
http://www.firebirdfaq.org/faq79/

Zitat:
Here's an example: if you multiply 9.12 with 8.11 (both numeric(18,2)) you would get 73.9632. If Firebird would store that into numeric(18,2) datatype, we would lose 0.0032. Doesn't look much, but when you have complex calculations, you can easily loose thousands (dollars or euros). Therefore, the result is stored in numeric(18,4).
  Mit Zitat antworten Zitat