![]() |
Negativ-Zahl umwandeln in Positiv-Zahl
Hallo zusammen,
folgendes Problem: Ich habe ein Wert z.B. -1.000,00 Euro Diesen möchte ich umwandeln in diesen Wert: 1.000,00 Euro D.h. ich suche eine Funktion, die eine negativ-Zahl in eine Positiv-Zahl schreibt. Hat Delphi so etwas schon?! Vielen Dank, Eppos |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
Hallo,
das sollte mit abs gehen. Grüße Klaus |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
Delphi-Quellcode:
:stupid:
if Zahl < 0 then
Zahl := Zahl * -1 |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
Zum einen Klaus01 seine Lösung ist vollkommen richtig und die Logik ermittelt noch diese Lösung:
Delphi-Quellcode:
@xX0815Xx: Eine Multiplikation ist deutlich aufwendiger...
if Wert < 0 then
Wert := -Wert; |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
abs?!
wo finde ich die Funktion |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
@ Eppos: DelphiHilfe öffnen und abs eintippen --> System.
@ Muetze: hast ja recht :D |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
ok, danke alles klaro,
habs am anfang nicht gefunden, hat er mir irgendwie nicht angezeigt, aber jetzt! :-) |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
Hallo
Was auch noch gut ist ist:
Delphi-Quellcode:
Liebe Grüsse
asm
NEG Wert end; Laufi |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
Zitat:
Wenn man da eine positive Zahl reinpacke, kommt sie negativ raus. So etwas wie abs() wäre:
Delphi-Quellcode:
asm
CMP wert, 0 JG @ENDE NEG wert @ENDE: end; |
Re: Negativ-Zahl umwandeln in Positiv-Zahl
ach so ok will er denn auch positive zahlen damit verwenden? :?
Aber dann sollte man es besser so machen nicht mit einen Jump!!!!! :shock:
Delphi-Quellcode:
Liebe grüsse
asm
MOV Temp, Wert NEG Temp CMOVNS Wert, Temp end Laufi |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:08 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz