[Vienna-pm] [OT] Rundungsverhalten von Perl

Christian Schoeller c_p_s at gmx.net
Thu Oct 23 11:17:05 CDT 2003


On Thu, Oct 23, 2003 at 05:18:32PM +0200, Thomas Klausner wrote:
> On Thu, Oct 23, 2003 at 04:40:40PM +0200, Christian Schoeller wrote:
> > Absatz "Modulo-Operator":
> > # Beide Werte werden vorher auf ihren ganzzahligen Wert reduziert.
> > 
> > Find' ich irgendwie merkwuerdig. Gibt es dafuer einen bestimmten
> > Grund, den zu durschauen mir noch nicht moeglich war?
> 
> ich denke mal das modulo nur bei ganzen Zahlen Sinn macht (allerdings bin
> ich kein (echter) Mathematiker..)

Stimmt natuerlich (obwohl ich auch keiner bin :-).

> Du kannst aber vorher einfach selber runden:
> 
> $a=4/3;
> $b=sprintf("%.0f",$a);  # auf die naechste ganze Zahl
> $c=sprintf("%.2f",$a);  # auf 2 Stellen nach dem Komma

Ah, danke sehr. "sprintf" hilft (bei was weisz ich noch nicht so
genau, weil ich derzeit sowieso nur mehr oder wenig sinnlose
Uebungsbeispiele vor mich hinschreib)!

Danke, C.
-- 
Christian Schoeller {Student}  | "It's easy to find something
MAIL {mailto:c_p_s at gmx.net}    | worth dying for. Do you have
HTTP {http://www.yaup.at.tt}   | anything worth living for?"
EBAY {c_p_s!}                  | --Lorien (Babylon 5)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/vienna-pm/attachments/20031023/0a3dc06c/attachment.bin


More information about the Vienna-pm mailing list