Qbasic 中# 和: 的用途是什么?

发布于 2024-11-12 02:11:01 字数 432 浏览 7 评论 0原文

我有一个遗留代码进行数学计算。据报道,它是用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

念三年u 2024-11-19 02:11:01

: 是行继续符,它允许您在同一行上链接多个语句。 a(i) = b: a(i+N) = c 相当于:

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:

a(i)=b
a(i+N)=c

# is a type specifier. It specifies that the number it follows should be treated as a double.

高速公鹿 2024-11-19 02:11:01

我已经有一段时间没有使用 QBasic 编程了,但我在高中时进行了大量的编程工作。 # 符号表示特定的数据类型。是将RHS值指定为双精度浮点数(类似于C中的1.0f使1.0成为单精度浮点数)。冒号也类似于 C 中的分号,它分隔不同的命令。例如:

a(i) = b: a(i+N) = c

is,在 C 中:

a[i] = b; a[i+N] = 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:

a(i) = b: a(i+N) = c

is, in C:

a[i] = b; a[i+N] = c;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文