By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

GMP and finding MSB of type mpz_t

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On 6 Dec 2003 14:58:29 -0800, Er********@sbcglobal.net (Ernst Berg)
wrote in comp.lang.c:
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
Nov 13 '05 #2

P: n/a
On Sun, 07 Dec 2003 00:23:11 GMT, in comp.lang.c , Jack Klein
<ja*******@spamcop.net> wrote:
On 6 Dec 2003 14:58:29 -0800, Er********@sbcglobal.net (Ernst Berg)
wrote in comp.lang.c:
I am learning about the GMP library and it is installed correctly
here.
As Jack says, GMP is offtopic 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?

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.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #3

P: n/a
On Sun, 07 Dec 2003 01:07:31 +0000, Mark McIntyre
<ma**********@spamcop.net> wrote in comp.lang.c:
On Sun, 07 Dec 2003 00:23:11 GMT, in comp.lang.c , Jack Klein
<ja*******@spamcop.net> wrote:
On 6 Dec 2003 14:58:29 -0800, Er********@sbcglobal.net (Ernst Berg)
wrote in comp.lang.c:
I am learning about the GMP library and it is installed correctly
here.
As Jack says, GMP is offtopic 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?


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.


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
Nov 13 '05 #4

P: n/a
On Sun, 07 Dec 2003 05:06:40 GMT, in comp.lang.c , Jack Klein
<ja*******@spamcop.net> wrote:
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....

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #5

P: n/a
On 6 Dec 2003 14:58:29 -0800
Er********@sbcglobal.net (Ernst Berg) wrote:
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.
--
Mark Gordon
Paid to be a Geek & a Senior Software Developer
Although my email address says spamtrap, it is real and I read it.
Nov 13 '05 #6

P: n/a
Mark Gordon <sp******@flash-gordon.me.uk> wrote in message news:<20031207002030.0ac66e8b.sp******@flash-gordon.me.uk>...
On 6 Dec 2003 14:58:29 -0800
Er********@sbcglobal.net (Ernst Berg) wrote:
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.

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
Nov 14 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.