All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scalqa.lang.float._methods.scala Maven / Gradle / Ivy

There is a newer version: 1.0
Show newest version
package scalqa; package lang; package float; import language.implicitConversions

/**
* ### Float Extension Methods 
*  
* Extension methods universaly avaialble for type scala.Float
*/
transparent trait _methods extends z.toPrimitives[Float]:
  extension(inline x: Float)
    /**
    * To option 
    *  
    * Returns Float.Opt for current value 
    * ``` 
    *   val o : Float.Opt = 12F.? 
    * ```
    */
    @tn("Opt")   inline def ?                          : SELF.Opt      = x.cast[SELF.Opt]
    /**
    * Range 
    *  
    * Returns Float.Range from current to given value 
    * ``` 
    *   (1F <> 10F).tp  // Prints  1.0 <> 10.0 
    * ```
    */
    @tn("range") inline def <> (inline to: Float)      : SELF.<>       = new SELF.<>(x,to,true)
    /**
    * Exclusive end range 
    *  
    * Returns Float.Range from current to given value exclusive 
    * ``` 
    *   (1F <>> 10F).tp  // Prints  1.0 <>> 10.0 
    * ```
    */
    @tn("rangeX")inline def <>>(inline to: Float)      : SELF.<>       = new SELF.<>(x,to,false)
    /**
    * Max 
    *  
    * Returns maximum of current or given value 
    *  
    * ``` 
    *   val v = 5F 
    *  
    *   v.atLeast(0).tp   // Prints 5.0 
    *  
    *   v.atLeast(10).tp  // Prints 10.0 
    * ```
    */
    infix        inline def atLeast(v: Float)          : Float         = {val w=x; if(w>v) w else v }
    /**
    * Min 
    *  
    * Returns minimun of current or given value 
    *  
    * ``` 
    *   val v = 5F 
    *  
    *   v.atMost(0).tp   // Prints 0.0 
    *  
    *   v.atMost(10).tp  // Prints 5.0 
    * ```
    */
    infix        inline def atMost(v: Float)           : Float         = {val w=x; if(w




© 2015 - 2024 Weber Informatics LLC | Privacy Policy