You will want two integer value for this value with decimal numbers.
value = x / y
I will use the format that we use in Germany.
in Germany format: 1.234,567
One thousand two hundred thirty-four comma five six seven
in English format: 1,234.567
One thousand two hundred thirty-four point five six seven
For the example value you can get y = 600 for solution.
0,aabbbbbbb * 100 = aa,bbbbbbb
with 0 <= aa < 100
and bbbbbbb with 6 different value (0000000 1666667 3333333 5000000 6666667 8333333) for 0 to 5.
x = 6 * aa + [0..5]
value is than x / 600
The last number 7 is round then 6,6666666... = 7
Here my code for the Test27.bat:
Code: Select all
@echo off
Setlocal EnableDelayedExpansion
set t0=000000000
set value2=600
for /F "usebackq" %%V in ("PeriodenZahlen.txt") DO (
SET V=%%V
echo !V!
set t3=!V!%t0%
:: value 0,aabbbbbbb :: with t1 as aa and t2 as bbbbbbb
set /a t1="10!t3:~2,2! %% 1000">nul
set t2=!t3:~4,7!
if !t2!==0000000 set /a value1=!t1! * 6
if !t2!==1666667 set /a value1=!t1! * 6 + 1
if !t2!==3333333 set /a value1=!t1! * 6 + 2
if !t2!==5000000 set /a value1=!t1! * 6 + 3
if !t2!==6666667 set /a value1=!t1! * 6 + 4
if !t2!==8333333 set /a value1=!t1! * 6 + 5
:: echo ## !t1! ## !t2! ### !value1! / %value2%
echo !t3:~0,11! = !value1! / %value2%
call Test27a !value1! %value2%
echo.
)
But you can have value that not will have the smallest value.
The gratest cammon divide number is 12.
12 / 600 = 1 / 50
This will make the batch Test27a.bat:
Code: Select all
@echo off
if #%1#==## (echo Error with the value1 and value2.)&goto :eof
if #%2#==## (echo Error with the value2.)&goto :eof
set v1=%1
set v2=%2
if %v1% lss %v2% (set v3=%v1%) & (set v1=%v2%) & (set v2=!v3!)
:here
:: echo %v1% %v2%
set v3=
set /a v3=v1 - (v2 * (v1 / v2))
:: echo %v3%
if not %v3%==0 (set v1=%v2%) & (set v2=%v3%) & goto :here
:: here the results
set v3=%v2%
set /a v1=%1 / v3
set /a v2=%2 / v3
echo %1 / %2 = %v1% / %v2%
If you want to check with other value as the 600.
Here the mathematic:
for /l %g in (2, 1, %f%) do
for /l %h in (1, 1, !g!) do
you will check with this value
1/2
1/3
2/3
1/4
2/4
3/4
...
Here is a example for calculate the digits value with xx numbers.
1.234,000 000 / 6
1234 / 6 = 205
1234 - 6 * 205 = 4
4 * 1000 = 4000
4000 / 6 = 666
4000 - 6 * 666 = 4
4 * 1000 = 4000
4000 / 6 = 666
4000 - 6 * 666 = 4
The last number is NOT rounded.
The solution with 6 digitals not rounded is:
1.234 / 6 = 205,666 666
If you want rounded after 3 digits numbers.
666 + 500 = 1166
1166 / 1000 = 1
205,666 + 0,001 = 205,667
I will not write this batch in this time.