Rev 206 |
Rev 252 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
public final class DUBwiseHelper
{
public final static String ip_digit_zeroes
(int digit
)
{ return "" + digit/
100 +
"" +
(digit/
10)%10 +
"" +
(digit
)%10
; }
public final static String ip_str
(int[] ip,
boolean with_zeroes
)
{
if(with_zeroes
)
return ip_digit_zeroes
(ip
[0]) +
"." +ip_digit_zeroes
(ip
[1]) +
"."+ip_digit_zeroes
(ip
[2]) +
"."+ip_digit_zeroes
(ip
[3]) +
":"+ip_digit_zeroes
(ip
[4]) ;
else
return ip
[0]+
"."+ip
[1]+
"."+ip
[2]+
"."+ip
[3]+
":"+ip
[4];
}
public final static int pow
(int val,
int pow
)
{
int res=
1;
for (int p=
0;p
<pow
;p++
)
res
*=val
;
return res
;
}
public final static int mod_decimal
(int val,
int mod_power,
int modder,
int setter,
int clipper
)
{
int res=
0;
for (int power=
0;power
<4;power++
)
{
int act_digit=
(val/pow
(10,power
))%10
;
int new_digit=act_digit
;
if (power==mod_power
)
{
if (setter
!=-
1)
new_digit=setter
;
new_digit+=modder
;
if(new_digit
<0)
new_digit=
0;
if(new_digit
>clipper
)
new_digit=clipper
;
}
// new_digit=1;
res+=new_digit
*pow
(10,power
);
}
return res
;
}
}