[Vienna-pm] noch seltameres...
Carl A. Schreiber
gooly at gmx.at
Thu Mar 30 03:11:45 PST 2006
Am Donnerstag, 30. März 2006 10:25 schrieb Nagy Wilhelm:
> Hallo Leute,
>
> erstmal besten dank fuer eure hilfe.
>
> Wer gerne gruebelt...
>
> $sValue = 0.0001;
> $sValue *= 0.75;
> $sValue = sprintf('%f',$sValue);
>
> printf("%.5f\n",$sValue);
> printf("%.5f\n",$sValue+1-1);
> printf("%.5f\n",$sValue*1);
> printf("%.5f\n",$sValue/1);
>
>
> ergibt bei mir folgendes:
> ---------- DoProgram ----------
> 0.00007
> 0.00008
> 0.00007
> 0.00007
>
> Output completed (0 sec consumed) - Normal Termination
>
> Besonder spannend ist
> printf("%.5f\n",$sValue+1-1);
Hallo,
nimm doch
Math::Round;
(ich hab alle anderen Versuche praktisch aufgegeben..)
use Math::Round qw(:all);
my $sValue = 0.0001;
my $rounded = nearest( 0.00001, $sValue*0.75 );
$sValue *= 0.75;
$sValue = sprintf('%f',$sValue);
printf("sVal: %.5f\n",$sValue);
printf("sVal: %.5f\n",$sValue+1-1);
printf("sVal: %.5f\n",$sValue*1);
printf("sVal: %.5f\n",$sValue/1);
printf("rnd : %.5f\n",$rounded);
printf("rnd : %.5f\n",$rounded+1-1);
printf("rnd : %.5f\n",$rounded*1);
printf("rnd : %.5f\n",$rounded/1);
das ergibt:
sVal: 0.00007
sVal: 0.00008
sVal: 0.00007
sVal: 0.00007
rnd : 0.00008
rnd : 0.00008
rnd : 0.00008
rnd : 0.00008
ist doch weitaus vorhersehbarer ..
Calli
>
> This is perl, v5.8.6 built for MSWin32-x86-multi-thread
> (with 3 registered patches, see perl -V for more detail)
>
>
> _______________________________________________
> Vienna-pm mailing list
> Vienna-pm at pm.org
> http://mail.pm.org/mailman/listinfo/vienna-pm
More information about the Vienna-pm
mailing list