Interactive PowerBasic Forum

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Frank BrĂ¼bach on June 03, 2024, 01:53:37 PM

Title: Cast example
Post by: Frank BrĂ¼bach on June 03, 2024, 01:53:37 PM
I dont know If there's any Cast example for oxygen but I noticed its Working perfect with sbyte

'' cast example (freebasic) and oxygen translation
''
uses console

sbyte sb 'signed byte
sb=32.2
print " 32.2 "+sb ' result 32


'' freebasic
'' Print Cast( Byte, &h0080 ) '-128 ''

'' oxygen
''
sb=byte(&h0080)
print " byte ="+sb ' result: -128


'' will print 3 because the floating-point value will be converted to an Integer
'' (this Casting operator is equivalent to using CInt)
''
'' Print Cast( Integer, 3.1 ) '3

'' oxygen
''

sb=integer(3.1)
print " integer 3.1 =" + sb ' result: 3

wait
Title: Re: Cast example
Post by: Charles Pegge on June 03, 2024, 06:43:17 PM
in o2, byte and ubyte are unsigned, sbyte is signed. You can also cast as char:

int a=43
print cast byte a  '43'  same as ubyte
print cast char a  '+'