![]() |
|
#1
|
|||
|
|||
need a lot of helpOk I have a few questions for all of you out there, any help is greatly appreciated.
Is there a way to find the last 6 digits of say a 8 digit number? Ex. I have a number of 12345678, I want to get 345678. Also how do I continuosly multiply by a certain number? What I mean by this is if I want to multiply numbers by 2 all the time. Ex. I start with the number 4. 4*2 = 8. How do I then multiply 8 by 2 without defining a new variable? Here's what i got: CPP / C++ / C Code:
Thanks for any feedback |
|
#2
|
|||
|
|||
|
Hi,
I am not shoure if this is eficient way to do this but if you have for example number 123456789 and you want to get let`s say last 8 numbers then you can do folowing.. CPP / C++ / C Code:
after this loop numb should be 12, but newnumb 3456789.. also take into account that unsigned long can hold the numbers only to 2^32, so if you have to deal with really large numbers, it is better to use strings or arrays of characters... for your second question if I understood it corectly it is quite simple: you just need to use loop: CPP / C++ / C Code:
while (i<16000).. of course such loop is quite useless unless you add something in it`s body, but that is up to you.. hope that helps |
|
#3
|
|||
|
|||
|
How would you go about putting a random number inside of a string? Whenever I try it outputs a bunch of weird characters.
Also the above newnumb does not give last of the number. It gives a 3 digit number, unless I pasted it wrong. Also, if there was a way to reverse the above step would be helpful. It gives 123456789 then 12345678 and so on. Last edited by rjd72285 : 26-Oct-2003 at 12:31.
|
|
#4
|
|||
|
|||
|
My aoollogies there was bug i the code...
the code should look like this: ---------------- CPP / C++ / C Code:
About strings.. I am not too shoure because I have not used strings in c++ too muc, but to my mind you should just randomize number and store the value in some variable, then you can use on of these funtions that converts numbers to strings.. I think one of them was sprintf.. is should be used something like this.. sprintf(target char buffer, %d, integer); this funtion is included in on of the standart c libraries not shoure which.. I suggest to read more about this funtion in help or manuali if you have one.. |
Recent GIDBlog
Developing GUIs with wxPython (Part 2) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HELP!: find window width? Center a <div>? | Kingherc | Web Design Forum | 2 | 06-Jul-2003 05:25 |
| auto number | skyloon | MySQL / PHP Forum | 1 | 30-Jun-2003 08:33 |
| How do I find the Unix log file route? | jrobbio | Web Hosting Forum | 4 | 04-Feb-2003 07:40 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The