问题描述
I face a problem with variable data type in vb.net; it is a simple code but I can't get the right result.
请考虑以下代码:
Dim x十进制
按小数表示的数字
将z设为小数位
x = 57D ^ 23D
x = 57D ^ 23D
y = 77D
z = x Mod y
仅使用mod函数,结果是错误的, 何时 span> I 搜索关于最大数据类型使用它来解决此问题,但我找不到任何解决方案.
just using mod function and the result is wrong, when check it by calculator the result is different.I search regarding to what is the largest data type to use it to pass this problem , but I can't found any solution.
我使用了Decimal数据类型.
有人有个好主意吗?
推荐答案
返回什么结果,您期望什么.另外,z的赋值将不会编译,因为这仅对Double类型有效.
What result is being returned and what did you expect. Also, the assignment for z will not compile as this is only valid for type Double.
将这两个语句添加到包含您的代码的文件顶部,然后重新编译以查看错误
Add these two statements to the top of the file which has your code and re-compile to see the errors
Option Strict On
Option Infer Off
这篇关于变量数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!