compile -w all
[update: simplified]
Code: Select all
/'
if fail: comparing .z * 1/0
fbc -w all
additional note: <typecast>(expression)
fail: (..), cint(..)
good: cbool(..), clng(..)
'/
type v
as single z
declare operator cast as string
End Type
operator v.cast as string
return str(z)
end operator
operator *(l as v,r as single) as v: return type(l.z*r): end operator
sub test( a as v, b as v )
if a.z > b.z then
var k = a.z > b.z
? a.z, b.z
print "if statement thinks these are different"
print
print "assigned var inside block says they are equal (correct)"
? "a > b ?:"; k
endif
End Sub
dim as v a,b
a*=(1/0)
b*=(1/0)
test a,b
[old version]
Code: Select all
/'
v3( all elems ) * 1/0
.x .y .z become #nan
'/
type v3
as single x,y,z
declare operator cast as string
End Type
operator v3.cast as string
return str(x) + " " + str(y) + " " + str(z)
end operator
operator *(l as v3,r as single) as v3: return type(l.x*r,l.y*r,l.z*r): end operator
' -------------------------------------
Type sort_type as v3
' -------------------------------------
#define dot .z
sub test(a() As sort_type)
for J as long = 1 to Ubound(a)
if a(J)dot > a(0)dot then
var k = a(J)dot > a(0)dot
? a(j)dot, a(0)dot
print "they are equal. if statement should not be triggered"
? "a > b ?:"; k
endif
next
End Sub
var u = 1
dim as v3 a(1)
dim as v3 dv(ubound(a))
for i as long = 0 to u
dv(i) = a(i)*(1/0)
next
test dv()