Thread Auf 2. Kommastelle runden? (31 answers)
Opened by Gast at 2008-05-07 02:31

Dubu
 2008-05-08 15:29
#109435 #109435
User since
2003-08-04
2145 Artikel
ModeratorIn + EditorIn

user image
Runden (von Dezimalbrüchen auf Binärsystemen) ist Glückssache:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ perl -le 'for ($i = 0; $i < 0.101; $i += 0.005) { printf "%f :  %.2f <=> %f\n", $i, $i, int($i*100+0.5)/100};'
0.000000 : 0.00 <=> 0.000000
0.005000 : 0.01 <=> 0.010000
0.010000 : 0.01 <=> 0.010000
0.015000 : 0.01 <=> 0.020000
0.020000 : 0.02 <=> 0.020000
0.025000 : 0.03 <=> 0.030000
0.030000 : 0.03 <=> 0.030000
0.035000 : 0.04 <=> 0.040000
0.040000 : 0.04 <=> 0.040000
0.045000 : 0.04 <=> 0.050000
0.050000 : 0.05 <=> 0.050000
0.055000 : 0.05 <=> 0.050000
0.060000 : 0.06 <=> 0.060000
0.065000 : 0.06 <=> 0.060000
0.070000 : 0.07 <=> 0.070000
0.075000 : 0.07 <=> 0.080000
0.080000 : 0.08 <=> 0.080000
0.085000 : 0.09 <=> 0.090000
0.090000 : 0.09 <=> 0.090000
0.095000 : 0.10 <=> 0.100000
0.100000 : 0.10 <=> 0.100000


perldoc -q floor

View full thread Auf 2. Kommastelle runden?