Advertisement
4_2005-2006 Math/ Dates #155251

Round, Ceiling, Floor Function

I found the round function from the planet source code before and I grouped it with my own ceil and floor function together. I hope these could help someone who don't want to use the round and format function to handle the numeric information.

AI

Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Zdrojový kód
original-source
Public Function AdvRound(InValue As Double, InDecimal As Integer) As Double <br>
  Dim lDblProcess As Double <br>
 <br>  
  lDblProcess = InValue * (10 ^ InDecimal) <br>
  AdvRound = Int(lDblProcess + 0.5) / (10 ^ InDecimal) <br>
End Function <br>
 <br>
Public Function AdvCeil(InValue As Double, InDecimal As Integer) As Double <br>
  Dim lDblProcess As Double <br>
  
  lDblProcess = InValue * (10 ^ InDecimal) <br>
  If Int(lDblProcess) < lDblProcess Then <br>
    lDblProcess = Int(lDblProcess) + 1 <br>
  Else <br>
    lDblProcess = Int(lDblProcess) <br>
  End If <br>
  AdvCeil = lDblProcess / (10 ^ InDecimal) <br>
End Function <br>
 <br>
Public Function AdvFloor(InValue As Double, InDecimal As Integer) As Double <br>
  Dim lDblProcess As Double <br>
  lDblProcess = InValue * (10 ^ InDecimal) <br>
  AdvFloor = Int(lDblProcess) / (10 ^ InDecimal) <br>
End Function <br>
Původní komentáře (3)
Obnoveno z Wayback Machine