Qbasic 中# 和: 的用途是什么?
我有一个遗留代码进行数学计算。据报道,它是用 QBasic 编写的,并且可以在 VB6 下成功运行。我计划将代码编写成更新的语言/平台。为此,我必须首先逆向工作,并根据现有代码提出详细的算法。
问题是我无法理解几行语法:
Dim a(1 to 200) as Double
Dim b as Double
Dim f(1 to 200) as Double
Dim g(1 to 200) as Double
For i = 1 to N
a(i) = b: a(i+N) = c
f(i) = 1#: g(i) = 0#
f(i+N) = 0#: g(i+N) = 1#
Next i
根据我 9 年前使用 VB5 的工作,我猜测 a、f 和 g 是索引从 1 到 200 的双精度数组。但是,我完全迷失了这一点在 for 循环体内一起使用 # 和 : 。
I have a legacy code doing math calculations. It is reportedly written in QBasic, and runs under VB6 successfully. I plan to write the code into a newer language/platform. For which I must first work backwards and come up with a detailed algorithm from existing code.
The problem is I can't understand syntax of few lines:
Dim a(1 to 200) as Double
Dim b as Double
Dim f(1 to 200) as Double
Dim g(1 to 200) as Double
For i = 1 to N
a(i) = b: a(i+N) = c
f(i) = 1#: g(i) = 0#
f(i+N) = 0#: g(i+N) = 1#
Next i
Based on my work with VB5 like 9 years ago, I am guessing that a, f and g are Double arrays indexed from 1 to 200. However, I am completely lost about this use of # and : together inside the body of the for-loop.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
:
是行继续符,它允许您在同一行上链接多个语句。a(i) = b: a(i+N) = c
相当于:#
是类型说明符。它指定其后面的数字应被视为双精度数。:
is the line continuation character, it allows you to chain multiple statements on the same line.a(i) = b: a(i+N) = c
is equivalent to:#
is a type specifier. It specifies that the number it follows should be treated as a double.我已经有一段时间没有使用 QBasic 编程了,但我在高中时进行了大量的编程工作。 # 符号表示特定的数据类型。是将RHS值指定为双精度浮点数(类似于C中的1.0f使1.0成为单精度浮点数)。冒号也类似于 C 中的分号,它分隔不同的命令。例如:
is,在 C 中:
I haven't programmed in QBasic for a while but I did extensively in highschool. The # symbol indicates a particular data type. It is to designate the RHS value as a floating point number with double precision (similar to saying 1.0f in C to make 1.0 a single-precision float). The colon symbol is similar to the semicolon in C, as well, where it delimits different commands. For instance:
is, in C: