China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-13 22:05
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Question about whether batch files have the concept of data types? View 1,053 Replies 3
Original Poster Posted 2006-04-12 14:40 ·  中国 广东 珠海 电信
新手上路
Credits 8
Posts 2
Joined 2006-04-12 14:35
20-year member
UID 53709
Status Offline
Newbie question, as the title says........
I want to implement something like 1+1=2,, how do you do addition, subtraction, multiplication, and division in a batch file???
Floor 2 Posted 2006-04-12 16:56 ·  中国 福建 南平 电信
初级用户
Credits 197
Posts 33
Joined 2003-07-24 00:00
23-year member
UID 7424
Gender Male
Status Offline
On 2000 and XP systems you can use the SET command
Floor 3 Posted 2006-04-12 17:04 ·  中国 广东 珠海 电信
新手上路
Credits 8
Posts 2
Joined 2006-04-12 14:35
20-year member
UID 53709
Status Offline
Thanks to Jnwei1202 for the reply. Can you give an example?

@set myvar=1+1
@echo %myvar%

What it outputs is 1+1.........
Floor 4 Posted 2006-04-12 20:54 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
The set command should use the "/a" parameter, for example: set /a myvar=1+1

This parameter only works under Win2000/XP/2003 systems. The SET command is very powerful, and there are a lot of related posts on the forum.
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Forum Jump: