GMP and finding MSB of type mpz_t

E

Ernst Berg

I am learning about the GMP library and it is installed correctly
here.

My question, which I found no match (so far) in the reading of the
past few weeks of posting to this group,the FAQ, by searching the
newsgroup and web and by reading the docs, is : how do I find the MSB
of mpz_t?

I hope I didn't miss it if it was there.

Ernst
 
M

Mark Gordon

On 6 Dec 2003 14:58:29 -0800
I am learning about the GMP library and it is installed correctly
here.

My question, which I found no match (so far) in the reading of the
past few weeks of posting to this group,the FAQ, by searching the
newsgroup and web and by reading the docs, is : how do I find the MSB
of mpz_t?

I hope I didn't miss it if it was there.

During all that reading didn't you notice that we only discus standard C
here? GMP is off topic and we have no idea what mpz_t is, it could be a
pointer to an array of structs for all we know.

My guess is that you are probably trying to solve the wrong problem and
if you ask on a GMP mailing list, or somewhere else that GPM is on
topic, saying what you actually want to achieve then they will be able
to give you a sensible answer.
 
J

Jack Klein

I am learning about the GMP library and it is installed correctly
here.

My question, which I found no match (so far) in the reading of the
past few weeks of posting to this group,the FAQ, by searching the
newsgroup and web and by reading the docs, is : how do I find the MSB
of mpz_t?

I hope I didn't miss it if it was there.

Ernst

mpz_t is not a C language data type, we have no idea what it is.
Third party libraries are non-standard and therefore not topical here.
Try a group like gnu.gcc.help, perhaps.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
M

Mark McIntyre

As Jack says, GMP is offtopic here.

Again as Jack says without knowing the type of an mpz_t its tough to
say.
Third party libraries are non-standard and therefore not topical here.

I disagree - the answer to the question is in fact topical and can be
achieved using only standard C, once you know what the heck an mpz_t
is . Typically you right-shift the object by one less bit than its
width, to get the most significant bit.
 
J

Jack Klein

As Jack says, GMP is offtopic here.


Again as Jack says without knowing the type of an mpz_t its tough to
say.

I disagree - the answer to the question is in fact topical and can be
achieved using only standard C, once you know what the heck an mpz_t
is . Typically you right-shift the object by one less bit than its
width, to get the most significant bit.

First, the term "MSB" is ambiguous, because it is used by different
people at different times to mean either "most significant byte" or
"most significant bit".

In the second place, without knowing the type of an mps_t, it is not
just tough but impossible to know whether your suggestion is feasible
or not. What if mpz_t is a floating point type? An array? A
structure? Even if it is a signed integer, on typical implementations
your suggestion will yield the sign bit, not a value bit.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
M

Mark McIntyre

First, the term "MSB" is ambiguous, because it is used by different
people at different times to mean either "most significant byte" or
"most significant bit".

Agreed. It could also mean Major Stomatchromous Bolide. Clarity, thats
the OP's problem, but it doesn't ipso factor make it OT here, merely
unclear.
In the second place, without knowing the type of an mps_t, it is not
just tough but impossible to know whether your suggestion is feasible or not.

No so. The suggestion works irrespective of the underlying data type.
It is of course not the /entire/ solution but heck people are expected
to do a little thinking of their own round here.
What if mpz_t is a floating point type? An array? A
structure?

So what? Its still a block of memory. It still some bits. Which is the
most significant is open to interpretation of course. The OP should
make clear what precisely he wanted but I strongly suspect that the
hint of using bit shifts will get him to where he needs to be, once he
things about it.
Even if it is a signed integer, on typical implementations
your suggestion will yield the sign bit, not a value bit.

Which is still, by some interpretation, the MSB. After all, which has
the largest effect on the value of the number? The OP really needs to
clarify what they want....
 
E

Ernst Berg

Mark Gordon said:
On 6 Dec 2003 14:58:29 -0800


During all that reading didn't you notice that we only discus standard C
here? GMP is off topic and we have no idea what mpz_t is, it could be a
pointer to an array of structs for all we know.

My guess is that you are probably trying to solve the wrong problem and
if you ask on a GMP mailing list, or somewhere else that GPM is on
topic, saying what you actually want to achieve then they will be able
to give you a sensible answer.


Yes indeed I see that it is off topic now.

To answer a question common to all replys it's the GNU Multiple
Precision Arithmetic Library. GNU MP is a portable library written in
C for arbitrary precision arithmetic on integers, rational numbers,
and floating-point numbers. It aims to provide the fastest possible
arithmetic for all applications that need higher precision than is
directly supported by the basic C types.


Also I did join the mailing list and do understand how to find the MSB
of type mpz_t now. I thank this group for reading my request.

I have other questions that will be on topic.

Again thank you for your time.

Ernst
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top