# Making a long with int

I tried this code, but it works not!! :drooling_face:

long wWholeValue = 00000L; int wDigitOne = 5;int wDigitTwo = 5; int wDigitThree = 5; int wDigitFour = 5;int wDigitFive = 5;

wWholeValue = long((long(long(wDigitFive)*10000L))+long(wDigitFour*1000)+long(wDigitThree*100)+long(wDigitTwo*10)+long(wDigitOne));

whats the best way to achieve a the expected result?

poll: vote for the one that you think should happen next. 1) Arduino should go away with long type numbers. 2) ejahable needs to keep asking about long type numbers in this forum until he gets proficient. 3) The reference documentation for long numbers needs some tune up.

4) you need to complete your question. What do you expect?

What do you expect?

Equally important, what did you get and how do you know that's what you got?

You could avoid all that casting by making wDigitOne, wDititTwo, etc. long. You could also build the number one digit at a time to see where the process is producing results other than what you expect.

1) Arduino should go away with long type numbers.

Because you don't understand them? Not a chance.

2) ejahable needs to keep asking about long type numbers in this forum until he gets proficient.

Even better, ejahable needs to get a book and do some reading.

3) The reference documentation for long numbers needs some tune up.

There's nothing wrong with the documentation. Your understanding of the documentation is a different story.

Okay im sorry for the tone of my post last night, I was totally frustrated.
I expect to learn how to properly use long type numbers!!
everything else comes after. Would you mind helping out in this algorythm?

thanks ejahable

Well, why don't you do as PaulS suggested, and break the problem down, digit by digit? Is your test method flawed? This will help you understand where the problem is likely to occur in future, and how to avoid it. Randomly scattering casts around makes for an unreadable sketch.

Taking your code and turning it into a working sketch:

``````void setup ()
{
Â  long wWholeValue = 00000L;
Â  int wDigitOne = 5;
Â  int wDigitTwo = 5;
Â  int wDigitThree = 5;
Â  int wDigitFour = 5;
Â  int wDigitFive = 5;
Â  wWholeValue = long((long(long(wDigitFive)*10000L))+long(wDigitFour*1000)+long(wDigitThree*100)+long(wDigitTwo*10)+long(wDigitOne));

Â  Serial.begin (115200);
Â  Serial.println (wWholeValue);
}

void loop () {}
``````

Output:

``````55555
``````

You've got me curious now. What did you expect? Some other number?

Besides, what are you really trying to do?

It sometimes, comes up with different numbers. Ie.55554. And the program gets hang up at this point. I don't want to change the individual numbers to long bc it would require me to change 80 percent of the other code.

It sometimes,

Please, post all your code.

I isolated the problem to this part of the program by making another program just testing it. Then I used serial communications to see the result. I'm not at home right now, n don't have it with me ill post it tonite. Thanks.

Just look over the code again with a different set of eyes and notice that i copied a counter. lol my bad :zipper_mouth_face: I should not program after 12hrs of work, fatigue really hits in. :roll_eyes:

Thanks for dealing with me!!