The maximum number that can be correctly processed is 2147483647, which is a 31-bit binary number. An error occurs at the 32nd bit. The version of moderator 3742668 is the same. Entering 2147483648 causes an error. Although the precision can reach 4294967295 by judging the number of shifts, I don't encounter such a large number in application, so I won't bother much.
@echo off
setlocal enabledelayedexpansion
set hexstr=0 1 2 3 4 5 6 7 8 9 A B C D E F
set d=0
for %%i in (%hexstr%) do (set d!d!=%%i&set/a d+=1)
set/p scanf=The maximum number that can be correctly processed is , please enter the decimal number to be converted:
if not defined scanf exit/b
set dec=%scanf%
call :d2h
if not defined hex set hex=0
echo The hexadecimal of %dec% is: 0x%hex%
pause>nul
exit/b
:d2h
if %scanf% equ 0 exit/b
set/a tscanf=%scanf%"&"15
set/a scanf">>="4
set hex=!d%tscanf%!!hex!
goto :d2h
Recent Ratings for This Post
( 4 in total)
Click for details
| Rater | Score | Time |
|---|---|---|
| redtek | +5 | 2007-01-07 21:04 |
| lxmxn | +10 | 2007-01-08 04:28 |
| ccwan | +5 | 2007-01-12 06:57 |
| electronixtar | +20 | 2007-01-13 06:56 |
