Skip to content

Commit 1ce741a

Browse files
authored
Update bool8.xw
1 parent ba5a39a commit 1ce741a

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

modules/std/types/composites/bool8.xw

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,24 @@ Const True8:Bool8=$1
194194
' version for the old Bool data type, per example NandBool(False,False) who will returns a heavy int32 as boolean,
195195
' but Nand:Bool8(False,False) will returns a light byte as boolean.
196196

197-
' Conversion from/to the old bool type
197+
' Conversion from/to the old bool type and ternary operator's result
198+
199+
#rem monkeydoc Bool8 to Ternary.
200+
@author iDkP from GaragePixel
201+
@since 2025-07-21
202+
Implicite conversion from bool to int is possible. In this case:
203+
- if v=True8 return 1
204+
- if v=False8 return 0
205+
But this function is special:
206+
- if v=True8 return 1
207+
- if v=False8 return -1
208+
... as it's intented to be used to cast a binary compare functions, sometimes with a sort.
209+
#end
210+
Function Bool8ToTernary:Int( v:Bool8 )
211+
'if v=true return 1
212+
'if v=false return -1
213+
Return v=False8 ? -1 Else v
214+
End
198215

199216
Function FromBool:Bool8(this:Bool)
200217
Return Cast<Bool8>(this)

0 commit comments

Comments
 (0)