From c93efe8966532b76872938233244399bfb426134 Mon Sep 17 00:00:00 2001 From: "mingw@yandex.ru" Date: Wed, 12 Jan 2022 04:51:32 +0500 Subject: [PATCH] Added new funcs... minimum and maximum numbers with three and four arguments. I'm not sure if it's necessary... however, the code becomes more readable. PS:don't know.. does the directive "in line" work - just in case I wrote them. Local myMax:Int=Max( a,Max( Max( b,c ),d ) ) --->>> Local myMax:Int=Max( a,b,c,d ) --- blitz.mod/builtin.bmx | 467 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 467 insertions(+) diff --git a/blitz.mod/builtin.bmx b/blitz.mod/builtin.bmx index b34be548..590fc02e 100644 --- a/blitz.mod/builtin.bmx +++ b/blitz.mod/builtin.bmx @@ -9,6 +9,32 @@ Function Max:Int(a:Int, b:Int) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #Int arguments. +End Rem +Function Max:Int( a:Int,b:Int,c:Int ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #Int arguments. +End Rem +Function Max:Int( a:Int,b:Int,c:Int,d:Int ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function + Rem bbdoc: Returns the larger of the two #Long arguments. End Rem @@ -19,6 +45,32 @@ Function Max:Long(a:Long, b:Long) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #Long arguments. +End Rem +Function Max:Long( a:Long,b:Long,c:Long ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #Long arguments. +End Rem +Function Max:Long( a:Long,b:Long,c:Long,d:Long ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function + Rem bbdoc: Returns the larger of the two #Float arguments. End Rem @@ -29,6 +81,32 @@ Function Max:Float(a:Float, b:Float) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #Float arguments. +End Rem +Function Max:Float( a:Float,b:Float,c:Float ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #Float arguments. +End Rem +Function Max:Float( a:Float,b:Float,c:Float,d:Float ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function + Rem bbdoc: Returns the larger of the two #Double arguments. End Rem @@ -39,6 +117,32 @@ Function Max:Double(a:Double, b:Double) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #Double arguments. +End Rem +Function Max:Double( a:Double,b:Double,c:Double ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #Double arguments. +End Rem +Function Max:Double( a:Double,b:Double,c:Double,d:Double ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function + Rem bbdoc: Returns the larger of the two #Byte arguments. End Rem @@ -49,6 +153,32 @@ Function Max:Byte(a:Byte, b:Byte) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #Byte arguments. +End Rem +Function Max:Byte( a:Byte,b:Byte,c:Byte ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #Byte arguments. +End Rem +Function Max:Byte( a:Byte,b:Byte,c:Byte,d:Byte ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function + Rem bbdoc: Returns the larger of the two #Short arguments. End Rem @@ -59,6 +189,32 @@ Function Max:Short(a:Short, b:Short) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #Short arguments. +End Rem +Function Max:Short( a:Short,b:Short,c:Short ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #Short arguments. +End Rem +Function Max:Short( a:Short,b:Short,c:Short,d:Short ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function + Rem bbdoc: Returns the larger of the two #UInt arguments. End Rem @@ -69,6 +225,32 @@ Function Max:UInt(a:UInt, b:UInt) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #UInt arguments. +End Rem +Function Max:UInt( a:UInt,b:UInt,c:UInt ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #UInt arguments. +End Rem +Function Max:UInt( a:UInt,b:UInt,c:UInt,d:UInt ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function + Rem bbdoc: Returns the larger of the two #ULong arguments. End Rem @@ -79,6 +261,32 @@ Function Max:ULong(a:ULong, b:ULong) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #ULong arguments. +End Rem +Function Max:ULong( a:ULong,b:ULong,c:ULong ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #ULong arguments. +End Rem +Function Max:ULong( a:ULong,b:ULong,c:ULong,d:ULong ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function + Rem bbdoc: Returns the larger of the two #Size_T arguments. End Rem @@ -89,6 +297,31 @@ Function Max:Size_T(a:Size_T, b:Size_T) Inline Return a End Function +Rem +bbdoc: Returns the larger of the three #Size_T arguments. +End Rem +Function Max:Size_T( a:Size_T,b:Size_T,c:Size_T ) Inline + If b>a + If c>b Then Return c Else Return b + End If + If c>a Then Return c Else Return a +End Function + +Rem +bbdoc: Returns the larger of the four #Size_T arguments. +End Rem +Function Max:Size_T( a:Size_T,b:Size_T,c:Size_T,d:Size_T ) Inline + If b>a + If c>b + If d>c Then Return d Else Return c + End If + If d>b Then Return d Else Return b + End If + If c>a + If d>c Then Return d Else Return c + End If + If d>a Then Return d Else Return a +End Function Rem @@ -101,6 +334,32 @@ Function Min:Int(a:Int, b:Int) Inline Return a End Function +Rem +bbdoc: Returns the lesser of the three #Int arguments. +End Rem +Function Min:Int( a:Int,b:Int,c:Int ) Inline + If b