Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Julia 在布尔上下文中使用的非布尔(UInt16)_Julia - Fatal编程技术网

Julia 在布尔上下文中使用的非布尔(UInt16)

Julia 在布尔上下文中使用的非布尔(UInt16),julia,Julia,我得到一个错误: TypeError:在布尔上下文中使用非布尔(UInt16) 经过一些调试后,错误来自这个while循环 current_value = UInt16(6) bit = UInt16(8) while (current_value & bit) bit >>= 1 end 出什么问题了?经过一些测试后,Julia中的while循环似乎并不默认为true测试非零。所以我需要添加=0显式 current_value = UInt16(6) bit =

我得到一个错误: TypeError:在布尔上下文中使用非布尔(UInt16)

经过一些调试后,错误来自这个while循环

current_value = UInt16(6)
bit = UInt16(8)
while (current_value & bit)
    bit >>= 1
end

出什么问题了?

经过一些测试后,Julia中的while循环似乎并不默认为true测试非零。所以我需要添加
=0
显式

current_value = UInt16(6)
bit = UInt16(8)
while (current_value & bit != 0)
    bit >>= 1
end

哦,嘿,吉姆-欢迎来到光明的新未来!请参阅“与C、MATLAB、Perl、Python和Ruby不同,但与Java和其他一些更严格的类型化语言一样,如果条件表达式的值不是真或假,则为错误”