Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Curiosity in set /a (smaller number)

14 views
Skip to first unread message

cmon...@gmail.com

unread,
Nov 15, 2012, 5:13:50 AM11/15/12
to
I believed that the smaller number that accept set /a is:
-2147483647

If you write this:
Set /a -2147483648
you get a error message that say that numbers are limited to 32 bits.

But, the curiosity is that using the hexadecimal notation:
Set /a 0x80000000
you get:
-2147483648



frank.w...@gmail.com

unread,
Nov 15, 2012, 6:55:05 AM11/15/12
to
From cmontiers:
>If you write this:
>Set /a -2147483648
>you get a error message that say that numbers are
>limited to 32 bits.

>But, the curiosity is that using the hexadecimal
>notation:
>Set /a 0x80000000
>you get:
>-2147483648

I think they used a 64-bit compiler and did not
internally convert the negative decimal input to a
32-bit integer. Leaving it as a 64-bit integer
-2147483648 became 0x8000000000000000.

Frank

frank.w...@gmail.com

unread,
Nov 15, 2012, 9:31:50 AM11/15/12
to
From frank.westlake:
I don't think that this problem occurs with -1 so the
problem might not be what I described. I don't have a
Windows computer but I vaguely recall that 16-bit
integers are somehow related to this negative-integer
error. Try experimenting with decimal values at and near
0x8000.

To work around the problem I think I did something like

SET /A "ans=%decimalValue% & 0xFFFFFFFF"

I have a backup of my Windows computer on my Android so
I'll look through my scripts for the solution.

Frank

Herbert Kleebauer

unread,
Nov 15, 2012, 11:12:27 AM11/15/12
to
On 15.11.2012 11:13, cmon...@gmail.com wrote:
> I believed that the smaller number that accept set /a is:
> -2147483647
>
> If you write this:
> Set /a -2147483648
> you get a error message that say that numbers are limited to 32 bits.

Seems -(214748364) instead of (-214748364) is calculated.

But more surprising is the result of

set /a 0x888888888888888888888

http://www.dostips.com/forum/viewtopic.php?f=3&t=3758



0 new messages