
 Envoyé par 
Speakers
					 
				 
				@Bktero, la fonction fait ce que je veux en Python, voici un rapide capture d'écran de l'interpréteur
			
		 
	 
 Toi, tu n'as pas suivi mon lien 
Essaye de code :
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 
 | def round_and_print(f, places):
    print("{0:} --> {1:.53f}".format(f, f))
    fa = round(f, places)   
    print("{0:} --> {1:.53f}".format(fa, fa))
 
round_and_print(6.779, 1)
round_and_print(6.779, 2)
round_and_print(2.675, 1)
round_and_print(2.675, 2) | 
 
Il affiche des flottants avec beaucoup de chiffres après la virgule pour voir vraiment ce qu'il y a dedans.
Voici le résultat :
6.779 --> 6.77899999999999991473487170878797769546508789062500000
6.8 --> 6.79999999999999982236431605997495353221893310546875000
6.779 --> 6.77899999999999991473487170878797769546508789062500000
6.78 --> 6.78000000000000024868995751603506505489349365234375000
2.675 --> 2.67499999999999982236431605997495353221893310546875000
2.7 --> 2.70000000000000017763568394002504646778106689453125000
2.675 --> 2.67499999999999982236431605997495353221893310546875000
2.67 --> 2.66999999999999992894572642398998141288757324218750000
6.779 --> 6.779000000000000
6.8 --> 6.800000000000000
6.779 --> 6.779000000000000
6.78 --> 6.780000000000000
2.675 --> 2.675000000000000
2.7 --> 2.700000000000000
2.675 --> 2.675000000000000
2.67 --> 2.670000000000000
 
						
					
Partager