Floor
Result = Floor(Value#)
 
Parameters:

    Value# = The value you wish to floor
Returns:

    Result = The truncated integer
 

      The Floor function returns a floating-point value representing the largest integer that is less than or equal to Value#.

      Functions like floor and int are useful when we don't want PlayBASIC to perform any rounding operations when moving the result of a floating point expression to an integer variable/array.



FACTS:

     * Int and Floor are functionality the same.



Mini Tutorial:




  
  
; set up a for not loop
  For lp=0 To 100 Step 10
     
   ; make V# equal to the loop counter divided by 100
     v#=lp/100.0
     Print "   V#="+Str$(V#)
     
   ; display V#  trancated by INT()
     Print "  Int:"+Str$(Int(V#))
     
   ; display V#  trancated by FLOOR()
     Print "Floor:"+Str$(Floor(V#))
     
  Next
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  




This example would output.

  
  
  V#=0.0
  Int:0
  Floor:0
  V#=0.1
  Int:0
  Floor:0
  V#=0.2
  Int:0
  Floor:0
  V#=0.3
  Int:0
  Floor:0
  V#=0.4
  Int:0
  Floor:0
  V#=0.5
  Int:0
  Floor:0
  V#=0.6
  Int:0
  Floor:0
  V#=0.7
  Int:0
  Floor:0
  V#=0.8
  Int:0
  Floor:0
  V#=0.9
  Int:0
  Floor:0
  V#=1.0
  Int:1
  Floor:1
  
  
  

 
Related Info: Ceil | Int | RoundDown | RoundUp :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com