Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [PHP] Arrotondamento stravagante

    Ciao a tutti!!
    Mi servirebbe arrontondare un numero con la virgola...ma non il metodo classico..cioè vorrei fare una cosa del genere:

    34, 134 --> 34
    54, 234 --> 54
    1, 299 --> 1
    1, 300 --> 2
    3, 345 --> 4
    4, 4 --> 5
    7, 5 --> 8
    6, 87 --> 7

    invece di avere lo spartiacque sullo 0.5, averlo sullo 0.3...c'è un modo non troppo contorno per farlo in php?

    Grazie:-)
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  2. #2
    aggiungo 0.7 e poi tronco con intval()!
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.