|
hi friend's
i want to compute the square root of a number with 15,000,000 digits but i cant use the mathematic functions that already in librarys. so i have to compute this manually.but i don't know the formula of this work.
please help me immediately.
thank you
msma
|
|
|
|
|
To calculate a square root manually, these are the first steps:
- take a large sheet of paper
- write your number in the top left corner
- group the digits by two, form right to left
- figure out the square root of the leftmost group (which holds one or two digits)
- that gives you the first digit of the result
- estimate the second digit by checking if the square is still less than the original
number (using two groups now)
etc.
Good luck.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
How about a slide-rule! Yeah, I am old!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George,
I am sure the slide-rule is older than all of us, but I doubt it will give
sufficient precision, unless you know of a very special algorithm...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: I am sure the slide-rule is older than all of us, but I doubt it will give
sufficient precision
Actually, he didn't mention anything about precision!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Well, if one does not care much about precision, the answer is 12.
No need for a sheet of paper nor an abacus.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I guest that would work if the number was 144.(followed by 14,999,997 zeroes)! That would satisfy his requirements.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
No, it is a universal solution to a whole class of problems.
It was offered to all CPians by our colleague Malcolm Stuart, who ends a lot
of his contributions by the very good advice: "More functions should disregard
input values and just return 12. It would make life easier."
And I can confirm life is getting easier this way.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Please forgive my ignorance? What is a CPian? Please don't reply with "12".
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George,
no, if you want a number here, it is well over 4 million, and increasing
all the time.
For a definition, I refer to this week's third tip; Google offers about
1000 hits for CPian, most of them refering to inhabitants of CodeProject.
Unfortunately Wikipedia and MSDN are not up-to-date on this issue.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks, I am now enlightened! I didn't know I was a CPian. Now, I have the smarts to figure out this 1 Billion-lightyear wide void in space that is 10 Billion light years away. Thus, twelve might be a promising number.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
While possibly not directly related to square rooting, your last message
triggers the following intriguing question: how does one measure a void,
and more in particular a void of that size?
And would it be possible to do that without using mathematical functions too?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I've been trying your method since Saturday.
I'm not even close to being done with step 2 (15 million digits)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You mean you found a large sheet of paper that can hold 15,000,000 digits. Imagine the number of pencils and erasers you will consume. Would this qualify for a world's record and finding the square root?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi Mark,
here is a performance optimization for you:
you don't need all the digits to start calculating the square root, so what
you can do is note a few thousand digits, and move on to the next step
and determine the first thousand digits of the root.
Make sure to leave the space for the missing digits though, otherwise you
may have to restart everything later on.
furthermore what's the hurry? the question was not even marked "urgent"
or "somewhat urgent".
Hope you don't make any mistake in the process...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hello,
I want to launch a timer starting from a method which one has to declare, because I wants that a thread launches it.
of habitud the timer is launched starting from an event of click of a boutton
how to do it its without having an event of click.
Thank you,
aef
|
|
|
|
|
I am confused about what you want to do?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I have a beginners question. What does the code look like to use DrawLine
in C++ CLI? -- thanks
|
|
|
|
|
Here's one way:
<mshelp:link tabindex="0" keywords="T:System.Drawing.Graphics" xmlns:mshelp="http://msdn.microsoft.com/mshelp">Graphics^graphics = CreateGraphics();
Pen AzurePen(Color::Azure);
graphics->DrawLine(%AzurePen, 10, 10, 50, 50);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Of course, this line will disappear as soon as the form is invalidated. All drawing should occur in the paint event
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Heh! I didn't say where to put the code, nor was I asked! LOL
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Actually, IMHO, you shouldn't give too much more information than they ask for. You learn more from trying and failing (a.k.a. experience) than someone telling you as a by-the-way comment.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Also, I find the distance I drift away from what the OP really wanted is often directly proportional
to the amount of example code I type and/or copy
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Word!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|