How to define long?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
borodache
Posts: 1
Joined: 04 Feb 2018 10:15

How to define long?

#1 Post by borodache » 04 Feb 2018 11:07

How can I define a long that is bigger than 32 bit, because when I do so I receive "Invalid number. Numbers are limited to 32-bits of precision."

Thanks in Advance

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: How to define long?

#2 Post by dbenham » 04 Feb 2018 12:56

Batch does not have native support for integers larger than 32 bit.

So if you are dealing with large numbers, then the first suggestion is - don't use batch. Use some other scripting language that does support large numbers (even floating point), such as JScript, VBScript, or PowerShell.

If you really are committed to using batch, then you can use hybrid techniques to incorporate JScript, VBScript, or PowerShell into batch to handle large numbers.
Here is JEval.bat: viewtopic.php?t=6212
And a general discussion of batch hybrid techniques can be found at: viewtopic.php?t=5543

Or if you really insist, you can look into existing libraries of pure batch routines to work with large numbers. I haven't used either one, so I can't make a recommendation.
From Judago: viewtopic.php?t=7170
From Ron: viewtopic.php?f=3&t=8332


Dave Benham

Post Reply