From: Sanny on
I use String comparision and if "str.charat() is not '-'"

We add bit value to xx.

The below code takes long time as we need to do 50 "if" comparisions
each time the function is called.

Below is the sample Java Code:

================================

long xx=0; long bit=1;

if (Str.charAt(50)!='-') xx+=bit;bit++;
if (Str.charAt(49)!='-') xx+=bit;bit++;
if (Str.charAt(48)!='-') xx+=bit;bit++;
if (Str.charAt(47)!='-') xx+=bit;bit++;
if (Str.charAt(46)!='-') xx+=bit;bit++;
if (Str.charAt(45)!='-') xx+=bit;bit++;
if (Str.charAt(44)!='-') xx+=bit;bit++;
if (Str.charAt(43)!='-') xx+=bit;bit++;
if (Str.charAt(42)!='-') xx+=bit;bit++;
if (Str.charAt(41)!='-') xx+=bit;bit++;
if (Str.charAt(40)!='-') xx+=bit;bit++;
if (Str.charAt(39)!='-') xx+=bit;bit++;
if (Str.charAt(38)!='-') xx+=bit;bit++;
if (Str.charAt(37)!='-') xx+=bit;bit++;
if (Str.charAt(36)!='-') xx+=bit;bit++;
if (Str.charAt(35)!='-') xx+=bit;bit++;
if (Str.charAt(34)!='-') xx+=bit;bit++;
if (Str.charAt(33)!='-') xx+=bit;bit++;
if (Str.charAt(32)!='-') xx+=bit;bit++;
if (Str.charAt(31)!='-') xx+=bit;bit++;
if (Str.charAt(30)!='-') xx+=bit;bit++;
if (Str.charAt(29)!='-') xx+=bit;bit++;
if (Str.charAt(28)!='-') xx+=bit;bit++;
if (Str.charAt(27)!='-') xx+=bit;bit++;
if (Str.charAt(26)!='-') xx+=bit;bit++;
if (Str.charAt(25)!='-') xx+=bit;bit++;
if (Str.charAt(24)!='-') xx+=bit;bit++;
if (Str.charAt(23)!='-') xx+=bit;bit++;
if (Str.charAt(22)!='-') xx+=bit;bit++;
if (Str.charAt(21)!='-') xx+=bit;bit++;
if (Str.charAt(20)!='-') xx+=bit;bit++;
if (Str.charAt(19)!='-') xx+=bit;bit++;
if (Str.charAt(18)!='-') xx+=bit;bit++;
if (Str.charAt(17)!='-') xx+=bit;bit++;
if (Str.charAt(16)!='-') xx+=bit;bit++;
if (Str.charAt(15)!='-') xx+=bit;bit++;
if (Str.charAt(14)!='-') xx+=bit;bit++;
if (Str.charAt(13)!='-') xx+=bit;bit++;
if (Str.charAt(12)!='-') xx+=bit;bit++;
if (Str.charAt(11)!='-') xx+=bit;bit++;
if (Str.charAt(10)!='-') xx+=bit;bit++;
if (Str.charAt(9)!='-') xx+=bit;bit++;
if (Str.charAt(8)!='-') xx+=bit;bit++;
if (Str.charAt(7)!='-') xx+=bit;bit++;
if (Str.charAt(6)!='-') xx+=bit;bit++;
if (Str.charAt(5)!='-') xx+=bit;bit++;
if (Str.charAt(4)!='-') xx+=bit;bit++;
if (Str.charAt(3)!='-') xx+=bit;bit++;
if (Str.charAt(2)!='-') xx+=bit;bit++;
if (Str.charAt(1)!='-') xx+=bit;bit++;
if (Str.charAt(0)!='-') xx+=bit;bit++;


================================

Since most of the time taken is by the "if condition."

I am thinking of using

char mm='-';
int mm1=Character.getNumericValue(mm);

int mm2=Str.charAt(0);

int mm3=mm2-mm1;

Now if I subtract mm2-mm1=mm3 Then I have to have xx+=bit; only when
mm3==0;

I want to write an Math Equation that computes mm3 and when mm3 value
is "0" xx+=bit; is done.

I am not getting the clue how to develop this equation to get rid of
the "If conditions"

Please suggest some equation or any other way to do this in one
statement.

ENUMERATION? can these be used here to solve these "if conditions" in
one step?

Bye
Sanny
From: Knute Johnson on
On 7/14/2010 11:16 AM, Sanny wrote:
> I use String comparision and if "str.charat() is not '-'"
>
> We add bit value to xx.
>
> The below code takes long time as we need to do 50 "if" comparisions
> each time the function is called.
>
> Below is the sample Java Code:
>
> ================================
>
> long xx=0; long bit=1;
>
> if (Str.charAt(50)!='-') xx+=bit;bit++;
> if (Str.charAt(49)!='-') xx+=bit;bit++;
> if (Str.charAt(48)!='-') xx+=bit;bit++;
> if (Str.charAt(47)!='-') xx+=bit;bit++;
> if (Str.charAt(46)!='-') xx+=bit;bit++;
> if (Str.charAt(45)!='-') xx+=bit;bit++;
> if (Str.charAt(44)!='-') xx+=bit;bit++;
> if (Str.charAt(43)!='-') xx+=bit;bit++;
> if (Str.charAt(42)!='-') xx+=bit;bit++;
> if (Str.charAt(41)!='-') xx+=bit;bit++;
> if (Str.charAt(40)!='-') xx+=bit;bit++;
> if (Str.charAt(39)!='-') xx+=bit;bit++;
> if (Str.charAt(38)!='-') xx+=bit;bit++;
> if (Str.charAt(37)!='-') xx+=bit;bit++;
> if (Str.charAt(36)!='-') xx+=bit;bit++;
> if (Str.charAt(35)!='-') xx+=bit;bit++;
> if (Str.charAt(34)!='-') xx+=bit;bit++;
> if (Str.charAt(33)!='-') xx+=bit;bit++;
> if (Str.charAt(32)!='-') xx+=bit;bit++;
> if (Str.charAt(31)!='-') xx+=bit;bit++;
> if (Str.charAt(30)!='-') xx+=bit;bit++;
> if (Str.charAt(29)!='-') xx+=bit;bit++;
> if (Str.charAt(28)!='-') xx+=bit;bit++;
> if (Str.charAt(27)!='-') xx+=bit;bit++;
> if (Str.charAt(26)!='-') xx+=bit;bit++;
> if (Str.charAt(25)!='-') xx+=bit;bit++;
> if (Str.charAt(24)!='-') xx+=bit;bit++;
> if (Str.charAt(23)!='-') xx+=bit;bit++;
> if (Str.charAt(22)!='-') xx+=bit;bit++;
> if (Str.charAt(21)!='-') xx+=bit;bit++;
> if (Str.charAt(20)!='-') xx+=bit;bit++;
> if (Str.charAt(19)!='-') xx+=bit;bit++;
> if (Str.charAt(18)!='-') xx+=bit;bit++;
> if (Str.charAt(17)!='-') xx+=bit;bit++;
> if (Str.charAt(16)!='-') xx+=bit;bit++;
> if (Str.charAt(15)!='-') xx+=bit;bit++;
> if (Str.charAt(14)!='-') xx+=bit;bit++;
> if (Str.charAt(13)!='-') xx+=bit;bit++;
> if (Str.charAt(12)!='-') xx+=bit;bit++;
> if (Str.charAt(11)!='-') xx+=bit;bit++;
> if (Str.charAt(10)!='-') xx+=bit;bit++;
> if (Str.charAt(9)!='-') xx+=bit;bit++;
> if (Str.charAt(8)!='-') xx+=bit;bit++;
> if (Str.charAt(7)!='-') xx+=bit;bit++;
> if (Str.charAt(6)!='-') xx+=bit;bit++;
> if (Str.charAt(5)!='-') xx+=bit;bit++;
> if (Str.charAt(4)!='-') xx+=bit;bit++;
> if (Str.charAt(3)!='-') xx+=bit;bit++;
> if (Str.charAt(2)!='-') xx+=bit;bit++;
> if (Str.charAt(1)!='-') xx+=bit;bit++;
> if (Str.charAt(0)!='-') xx+=bit;bit++;
>
>
> ================================
>
> Since most of the time taken is by the "if condition."
>
> I am thinking of using
>
> char mm='-';
> int mm1=Character.getNumericValue(mm);
>
> int mm2=Str.charAt(0);
>
> int mm3=mm2-mm1;
>
> Now if I subtract mm2-mm1=mm3 Then I have to have xx+=bit; only when
> mm3==0;
>
> I want to write an Math Equation that computes mm3 and when mm3 value
> is "0" xx+=bit; is done.
>
> I am not getting the clue how to develop this equation to get rid of
> the "If conditions"
>
> Please suggest some equation or any other way to do this in one
> statement.
>
> ENUMERATION? can these be used here to solve these "if conditions" in
> one step?
>
> Bye
> Sanny

public class test {
public static void main(String[] args) {
String str = "lkee-sli2<F2-8s0--slk3vUIGN_-";
str = str.replaceAll("-","");
int len = str.length();
long xx = len * (len + 1) / 2;
System.out.println(xx);
}
}

--

Knute Johnson
email s/nospam/knute2010/

From: Knute Johnson on
On 7/14/2010 11:16 AM, Sanny wrote:
> I use String comparision and if "str.charat() is not '-'"
>
> We add bit value to xx.
>
> The below code takes long time as we need to do 50 "if" comparisions
> each time the function is called.
>
> Below is the sample Java Code:
>
> ================================
>
> long xx=0; long bit=1;
>
> if (Str.charAt(50)!='-') xx+=bit;bit++;
> if (Str.charAt(49)!='-') xx+=bit;bit++;
> if (Str.charAt(48)!='-') xx+=bit;bit++;
> if (Str.charAt(47)!='-') xx+=bit;bit++;
> if (Str.charAt(46)!='-') xx+=bit;bit++;
> if (Str.charAt(45)!='-') xx+=bit;bit++;
> if (Str.charAt(44)!='-') xx+=bit;bit++;
> if (Str.charAt(43)!='-') xx+=bit;bit++;
> if (Str.charAt(42)!='-') xx+=bit;bit++;
> if (Str.charAt(41)!='-') xx+=bit;bit++;
> if (Str.charAt(40)!='-') xx+=bit;bit++;
> if (Str.charAt(39)!='-') xx+=bit;bit++;
> if (Str.charAt(38)!='-') xx+=bit;bit++;
> if (Str.charAt(37)!='-') xx+=bit;bit++;
> if (Str.charAt(36)!='-') xx+=bit;bit++;
> if (Str.charAt(35)!='-') xx+=bit;bit++;
> if (Str.charAt(34)!='-') xx+=bit;bit++;
> if (Str.charAt(33)!='-') xx+=bit;bit++;
> if (Str.charAt(32)!='-') xx+=bit;bit++;
> if (Str.charAt(31)!='-') xx+=bit;bit++;
> if (Str.charAt(30)!='-') xx+=bit;bit++;
> if (Str.charAt(29)!='-') xx+=bit;bit++;
> if (Str.charAt(28)!='-') xx+=bit;bit++;
> if (Str.charAt(27)!='-') xx+=bit;bit++;
> if (Str.charAt(26)!='-') xx+=bit;bit++;
> if (Str.charAt(25)!='-') xx+=bit;bit++;
> if (Str.charAt(24)!='-') xx+=bit;bit++;
> if (Str.charAt(23)!='-') xx+=bit;bit++;
> if (Str.charAt(22)!='-') xx+=bit;bit++;
> if (Str.charAt(21)!='-') xx+=bit;bit++;
> if (Str.charAt(20)!='-') xx+=bit;bit++;
> if (Str.charAt(19)!='-') xx+=bit;bit++;
> if (Str.charAt(18)!='-') xx+=bit;bit++;
> if (Str.charAt(17)!='-') xx+=bit;bit++;
> if (Str.charAt(16)!='-') xx+=bit;bit++;
> if (Str.charAt(15)!='-') xx+=bit;bit++;
> if (Str.charAt(14)!='-') xx+=bit;bit++;
> if (Str.charAt(13)!='-') xx+=bit;bit++;
> if (Str.charAt(12)!='-') xx+=bit;bit++;
> if (Str.charAt(11)!='-') xx+=bit;bit++;
> if (Str.charAt(10)!='-') xx+=bit;bit++;
> if (Str.charAt(9)!='-') xx+=bit;bit++;
> if (Str.charAt(8)!='-') xx+=bit;bit++;
> if (Str.charAt(7)!='-') xx+=bit;bit++;
> if (Str.charAt(6)!='-') xx+=bit;bit++;
> if (Str.charAt(5)!='-') xx+=bit;bit++;
> if (Str.charAt(4)!='-') xx+=bit;bit++;
> if (Str.charAt(3)!='-') xx+=bit;bit++;
> if (Str.charAt(2)!='-') xx+=bit;bit++;
> if (Str.charAt(1)!='-') xx+=bit;bit++;
> if (Str.charAt(0)!='-') xx+=bit;bit++;
>
>
> ================================
>
> Since most of the time taken is by the "if condition."
>
> I am thinking of using
>
> char mm='-';
> int mm1=Character.getNumericValue(mm);
>
> int mm2=Str.charAt(0);
>
> int mm3=mm2-mm1;
>
> Now if I subtract mm2-mm1=mm3 Then I have to have xx+=bit; only when
> mm3==0;
>
> I want to write an Math Equation that computes mm3 and when mm3 value
> is "0" xx+=bit; is done.
>
> I am not getting the clue how to develop this equation to get rid of
> the "If conditions"
>
> Please suggest some equation or any other way to do this in one
> statement.
>
> ENUMERATION? can these be used here to solve these "if conditions" in
> one step?
>
> Bye
> Sanny

public class test {
public static void main(String[] args) {
String str = "lkee-sli2<F2-8s0--slk3vUIGN_-";
str = str.replaceAll("-","");
int len = str.length();
long xx = len * (len + 1) / 2;
System.out.println(xx);
}
}

--

Knute Johnson
email s/nospam/knute2010/

From: Sanny on
On Jul 14, 11:40 pm, Knute Johnson <nos...(a)rabbitbrush.frazmtn.com>
wrote:
> On 7/14/2010 11:16 AM, Sanny wrote:
>
>
>
>
>
> > I use String comparision and if "str.charat() is not '-'"
>
> > We add bit value to xx.
>
> > The below code takes long time as we need to do 50 "if" comparisions
> > each time the function is called.
>
> > Below is the sample Java Code:
>
> > ================================
>
> > long xx=0; long bit=1;
>
> >   if (Str.charAt(50)!='-') xx+=bit;bit++;
> >   if (Str.charAt(49)!='-') xx+=bit;bit++;
> >   if (Str.charAt(48)!='-') xx+=bit;bit++;
> >   if (Str.charAt(47)!='-') xx+=bit;bit++;
> >   if (Str.charAt(46)!='-') xx+=bit;bit++;
> >   if (Str.charAt(45)!='-') xx+=bit;bit++;
> >   if (Str.charAt(44)!='-') xx+=bit;bit++;
> >   if (Str.charAt(43)!='-') xx+=bit;bit++;
> >   if (Str.charAt(42)!='-') xx+=bit;bit++;
> >   if (Str.charAt(41)!='-') xx+=bit;bit++;
> >   if (Str.charAt(40)!='-') xx+=bit;bit++;
> >   if (Str.charAt(39)!='-') xx+=bit;bit++;
> >   if (Str.charAt(38)!='-') xx+=bit;bit++;
> >   if (Str.charAt(37)!='-') xx+=bit;bit++;
> >   if (Str.charAt(36)!='-') xx+=bit;bit++;
> >   if (Str.charAt(35)!='-') xx+=bit;bit++;
> >   if (Str.charAt(34)!='-') xx+=bit;bit++;
> >   if (Str.charAt(33)!='-') xx+=bit;bit++;
> >   if (Str.charAt(32)!='-') xx+=bit;bit++;
> >   if (Str.charAt(31)!='-') xx+=bit;bit++;
> >   if (Str.charAt(30)!='-') xx+=bit;bit++;
> >   if (Str.charAt(29)!='-') xx+=bit;bit++;
> >   if (Str.charAt(28)!='-') xx+=bit;bit++;
> >   if (Str.charAt(27)!='-') xx+=bit;bit++;
> >   if (Str.charAt(26)!='-') xx+=bit;bit++;
> >   if (Str.charAt(25)!='-') xx+=bit;bit++;
> >   if (Str.charAt(24)!='-') xx+=bit;bit++;
> >   if (Str.charAt(23)!='-') xx+=bit;bit++;
> >   if (Str.charAt(22)!='-') xx+=bit;bit++;
> >   if (Str.charAt(21)!='-') xx+=bit;bit++;
> >   if (Str.charAt(20)!='-') xx+=bit;bit++;
> >   if (Str.charAt(19)!='-') xx+=bit;bit++;
> >   if (Str.charAt(18)!='-') xx+=bit;bit++;
> >   if (Str.charAt(17)!='-') xx+=bit;bit++;
> >   if (Str.charAt(16)!='-') xx+=bit;bit++;
> >   if (Str.charAt(15)!='-') xx+=bit;bit++;
> >   if (Str.charAt(14)!='-') xx+=bit;bit++;
> >   if (Str.charAt(13)!='-') xx+=bit;bit++;
> >   if (Str.charAt(12)!='-') xx+=bit;bit++;
> >   if (Str.charAt(11)!='-') xx+=bit;bit++;
> >   if (Str.charAt(10)!='-') xx+=bit;bit++;
> >   if (Str.charAt(9)!='-') xx+=bit;bit++;
> >   if (Str.charAt(8)!='-') xx+=bit;bit++;
> >   if (Str.charAt(7)!='-') xx+=bit;bit++;
> >   if (Str.charAt(6)!='-') xx+=bit;bit++;
> >   if (Str.charAt(5)!='-') xx+=bit;bit++;
> >   if (Str.charAt(4)!='-') xx+=bit;bit++;
> >   if (Str.charAt(3)!='-') xx+=bit;bit++;
> >   if (Str.charAt(2)!='-') xx+=bit;bit++;
> >   if (Str.charAt(1)!='-') xx+=bit;bit++;
> >   if (Str.charAt(0)!='-') xx+=bit;bit++;
>
> > ================================
>
> > Since most of the time taken is by the "if condition."
>
> > I am thinking of using
>
> > char mm='-';
> >    int mm1=Character.getNumericValue(mm);
>
> > int mm2=Str.charAt(0);
>
> > int mm3=mm2-mm1;
>
> > Now if I subtract mm2-mm1=mm3 Then I have to have xx+=bit; only when
> > mm3==0;
>
> > I want to write an Math Equation that computes mm3 and when mm3 value
> > is "0" xx+=bit; is done.
>
> > I am not getting the clue how to develop this equation to get rid of
> > the "If conditions"
>
> > Please suggest some equation or any other way to do this in one
> > statement.
>
> > ENUMERATION? can these be used here to solve these "if conditions" in
> > one step?
>
> > Bye
> > Sanny
>
> public class test {
>      public static void main(String[] args) {
>          String str = "lkee-sli2<F2-8s0--slk3vUIGN_-";
>          str = str.replaceAll("-","");
>          int len = str.length();
>          long xx = len * (len + 1) / 2;
>          System.out.println(xx);
>      }
>
> }

That was just a sample. You have used Arithmetic Addition.

Say the function is little complex.

Below is the sample Java Code:

================================

long xx=0; long bit=1;

if (Str.charAt(50)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(49)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(48)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(47)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(46)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(45)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(44)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(43)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(42)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(41)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(40)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(39)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(38)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(37)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(36)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(35)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(34)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(33)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(32)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(31)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(30)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(29)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(28)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(27)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(26)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(25)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(24)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(23)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(22)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(21)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(20)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(19)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(18)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(17)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(16)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(15)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(14)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(13)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(12)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(11)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(10)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(9)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(8)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(7)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(6)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(5)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(4)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(3)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(2)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(1)!='-') xx+=bit;bit=bit<<1;
if (Str.charAt(0)!='-') xx+=bit;bit=bit<<1;


================================

What will you do in this case?

Bye
Sanny





From: Knute Johnson on
On 7/14/2010 11:49 AM, Sanny wrote:
> On Jul 14, 11:40 pm, Knute Johnson<nos...(a)rabbitbrush.frazmtn.com>
> wrote:
>> On 7/14/2010 11:16 AM, Sanny wrote:
>>
>>
>>
>>
>>
>>> I use String comparision and if "str.charat() is not '-'"
>>
>>> We add bit value to xx.
>>
>>> The below code takes long time as we need to do 50 "if" comparisions
>>> each time the function is called.
>>
>>> Below is the sample Java Code:
>>
>>> ================================
>>
>>> long xx=0; long bit=1;
>>
>>> if (Str.charAt(50)!='-') xx+=bit;bit++;
>>> if (Str.charAt(49)!='-') xx+=bit;bit++;
>>> if (Str.charAt(48)!='-') xx+=bit;bit++;
>>> if (Str.charAt(47)!='-') xx+=bit;bit++;
>>> if (Str.charAt(46)!='-') xx+=bit;bit++;
>>> if (Str.charAt(45)!='-') xx+=bit;bit++;
>>> if (Str.charAt(44)!='-') xx+=bit;bit++;
>>> if (Str.charAt(43)!='-') xx+=bit;bit++;
>>> if (Str.charAt(42)!='-') xx+=bit;bit++;
>>> if (Str.charAt(41)!='-') xx+=bit;bit++;
>>> if (Str.charAt(40)!='-') xx+=bit;bit++;
>>> if (Str.charAt(39)!='-') xx+=bit;bit++;
>>> if (Str.charAt(38)!='-') xx+=bit;bit++;
>>> if (Str.charAt(37)!='-') xx+=bit;bit++;
>>> if (Str.charAt(36)!='-') xx+=bit;bit++;
>>> if (Str.charAt(35)!='-') xx+=bit;bit++;
>>> if (Str.charAt(34)!='-') xx+=bit;bit++;
>>> if (Str.charAt(33)!='-') xx+=bit;bit++;
>>> if (Str.charAt(32)!='-') xx+=bit;bit++;
>>> if (Str.charAt(31)!='-') xx+=bit;bit++;
>>> if (Str.charAt(30)!='-') xx+=bit;bit++;
>>> if (Str.charAt(29)!='-') xx+=bit;bit++;
>>> if (Str.charAt(28)!='-') xx+=bit;bit++;
>>> if (Str.charAt(27)!='-') xx+=bit;bit++;
>>> if (Str.charAt(26)!='-') xx+=bit;bit++;
>>> if (Str.charAt(25)!='-') xx+=bit;bit++;
>>> if (Str.charAt(24)!='-') xx+=bit;bit++;
>>> if (Str.charAt(23)!='-') xx+=bit;bit++;
>>> if (Str.charAt(22)!='-') xx+=bit;bit++;
>>> if (Str.charAt(21)!='-') xx+=bit;bit++;
>>> if (Str.charAt(20)!='-') xx+=bit;bit++;
>>> if (Str.charAt(19)!='-') xx+=bit;bit++;
>>> if (Str.charAt(18)!='-') xx+=bit;bit++;
>>> if (Str.charAt(17)!='-') xx+=bit;bit++;
>>> if (Str.charAt(16)!='-') xx+=bit;bit++;
>>> if (Str.charAt(15)!='-') xx+=bit;bit++;
>>> if (Str.charAt(14)!='-') xx+=bit;bit++;
>>> if (Str.charAt(13)!='-') xx+=bit;bit++;
>>> if (Str.charAt(12)!='-') xx+=bit;bit++;
>>> if (Str.charAt(11)!='-') xx+=bit;bit++;
>>> if (Str.charAt(10)!='-') xx+=bit;bit++;
>>> if (Str.charAt(9)!='-') xx+=bit;bit++;
>>> if (Str.charAt(8)!='-') xx+=bit;bit++;
>>> if (Str.charAt(7)!='-') xx+=bit;bit++;
>>> if (Str.charAt(6)!='-') xx+=bit;bit++;
>>> if (Str.charAt(5)!='-') xx+=bit;bit++;
>>> if (Str.charAt(4)!='-') xx+=bit;bit++;
>>> if (Str.charAt(3)!='-') xx+=bit;bit++;
>>> if (Str.charAt(2)!='-') xx+=bit;bit++;
>>> if (Str.charAt(1)!='-') xx+=bit;bit++;
>>> if (Str.charAt(0)!='-') xx+=bit;bit++;
>>
>>> ================================
>>
>>> Since most of the time taken is by the "if condition."
>>
>>> I am thinking of using
>>
>>> char mm='-';
>>> int mm1=Character.getNumericValue(mm);
>>
>>> int mm2=Str.charAt(0);
>>
>>> int mm3=mm2-mm1;
>>
>>> Now if I subtract mm2-mm1=mm3 Then I have to have xx+=bit; only when
>>> mm3==0;
>>
>>> I want to write an Math Equation that computes mm3 and when mm3 value
>>> is "0" xx+=bit; is done.
>>
>>> I am not getting the clue how to develop this equation to get rid of
>>> the "If conditions"
>>
>>> Please suggest some equation or any other way to do this in one
>>> statement.
>>
>>> ENUMERATION? can these be used here to solve these "if conditions" in
>>> one step?
>>
>>> Bye
>>> Sanny
>>
>> public class test {
>> public static void main(String[] args) {
>> String str = "lkee-sli2<F2-8s0--slk3vUIGN_-";
>> str = str.replaceAll("-","");
>> int len = str.length();
>> long xx = len * (len + 1) / 2;
>> System.out.println(xx);
>> }
>>
>> }
>
> That was just a sample. You have used Arithmetic Addition.
>
> Say the function is little complex.
>
> Below is the sample Java Code:
>
> ================================
>
> long xx=0; long bit=1;
>
> if (Str.charAt(50)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(49)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(48)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(47)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(46)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(45)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(44)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(43)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(42)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(41)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(40)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(39)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(38)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(37)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(36)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(35)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(34)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(33)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(32)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(31)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(30)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(29)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(28)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(27)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(26)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(25)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(24)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(23)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(22)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(21)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(20)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(19)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(18)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(17)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(16)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(15)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(14)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(13)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(12)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(11)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(10)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(9)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(8)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(7)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(6)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(5)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(4)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(3)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(2)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(1)!='-') xx+=bit;bit=bit<<1;
> if (Str.charAt(0)!='-') xx+=bit;bit=bit<<1;
>
>
> ================================
>
> What will you do in this case?
>
> Bye
> Sanny

You should post what you want to know about. But this case is even
simpler, just shift bit the number of non - characters.

bit << len;

--

Knute Johnson
email s/nospam/knute2010/