<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">Il giorno 14 aprile 2015 01:26, Carpediem <span dir="ltr"><<a href="mailto:i.carpediem@tiscali.it" target="_blank">i.carpediem@tiscali.it</a>></span> ha scritto:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">A questo punto, quindi, se chiedo di stampare s invece che ritrovarmi il valore 1 ottengo 0<br></blockquote><div><br></div><div>Beh il punto è che stai chiedendo una cosa e ne vuoi un'altra. </div><div><br></div><div><div><span style="font-size:12.8000001907349px">>>> sb = 3287628061</span></div><div><span style="font-size:12.8000001907349px">>>> type(sb)</span></div><div><span style="font-size:12.8000001907349px"><type 'long'></span></div><div><span style="font-size:12.8000001907349px">>>> mb = sb / 60</span></div><div><span style="font-size:12.8000001907349px">>>> type(mb)</span></div><div><span style="font-size:12.8000001907349px"><type 'long'></span></div><div><span style="font-size:12.8000001907349px">>>> mb</span></div><div><span style="font-size:12.8000001907349px">54793801L</span></div><div><span style="font-size:12.8000001907349px">>>> m1 = int(mb)</span></div><div><span style="font-size:12.8000001907349px">>>> type(m1)</span></div><div><span style="font-size:12.8000001907349px"><type 'int'></span></div><div><div style><span style="font-size:12.8000001907349px">>>> m1</span></div><div style><span style="font-size:12.8000001907349px">54793801</span></div></div><div><span style="font-size:12.8000001907349px">>>> s = int ((mb-m1)*60)</span></div><div><span style="font-size:12.8000001907349px">>>> type(s)</span></div><div><span style="font-size:12.8000001907349px"><type 'int'></span></div><div><div style><span style="font-size:12.8000001907349px">>>> s</span></div><div style><span style="font-size:12.8000001907349px">0</span></div></div><div><br></div></div><div><span style="font-size:12.8000001907349px">Nel codice che hai scritto i decimali non sono presi in considerazione, perché stai facendo operazioni su interi. </span></div><div><span style="font-size:12.8000001907349px">Inoltre, la funzione int() non arrotonda ma converte, ciò vuol dire che 0.1 o 0.99 o 0.11111111111111112344 daranno lo stesso risultato: 0, che è la parte intera del numero.</span></div><div><span style="font-size:12.8000001907349px">Non si tratta di un problema di virgola mobile, ma un problema di funzione, come già ti dicevano usa round().</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Ciao</span></div></div><div><br></div>-- <br><div class="gmail_signature">____________________________<br>Giuseppe Amato<br>e-mail: <a href="mailto:giuamato@gmail.com" target="_blank">giuamato@gmail.com</a></div>
</div></div>