FAQ
Hi,

I find myself trying to covert some Python code to Go which uses
arbitrary large numbers.
The original Python code takes the square root and floors the result of
one of these numbers.

But, looking at Go's math/big package, I can't work out how square root
one of these numbers. There doesn't, at first glance, seem to be an
arbitrary "pow" function. Likewise the floor function.

As this isn't my usual area, I feel don't understanding something
fundamental. Does anyone have any pointers, or packages, or example code
that can point me in the right direction?

Thanks

Owen

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Tamás Gulácsi at Mar 1, 2016 at 10:31 pm
    Check https://golang.org/pkg/math/big/#example__sqrt2

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Alb Donizetti at Mar 1, 2016 at 11:11 pm
    For floor you have to use Float.Int()
    (https://golang.org/pkg/math/big/#Float.Int)

    I have Sqrt, Log and Pow implementations here:
    https://godoc.org/github.com/ALTree/floatutils

    DISCLAIMER: I don't guarantee correctness of the last decimal digit

    It's not a real library, more like a few experiments (I'd like to see at
    least Sqrt merged in
    math/big, but not right now, it's not tested enough).

    Il giorno martedì 1 marzo 2016 21:39:12 UTC+1, Owen Waller ha scritto:
    Hi,

    I find myself trying to covert some Python code to Go which uses arbitrary
    large numbers.
    The original Python code takes the square root and floors the result of
    one of these numbers.

    But, looking at Go's math/big package, I can't work out how square root
    one of these numbers. There doesn't, at first glance, seem to be an
    arbitrary "pow" function. Likewise the floor function.

    As this isn't my usual area, I feel don't understanding something
    fundamental. Does anyone have any pointers, or packages, or example code
    that can point me in the right direction?

    Thanks

    Owen
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Owen Waller at Mar 1, 2016 at 11:33 pm
    Ah ha. Thank you very much Alberto. This should get me a lot further.

    On a more general point. Given that you have written this, is math/big
    might lacking some more functions. Do you, or anyone else, have an list
    of functions that should be added?

    This isn't my area by any means, but if it scratches an itch, I'll offer
    to help.

    Owen
    On Tue, 2016-03-01 at 15:11 -0800, alb.donizetti@gmail.com wrote:
    For floor you have to use Float.Int()
    (https://golang.org/pkg/math/big/#Float.Int)

    I have Sqrt, Log and Pow implementations here:
    https://godoc.org/github.com/ALTree/floatutils

    DISCLAIMER: I don't guarantee correctness of the last decimal digit

    It's not a real library, more like a few experiments (I'd like to see
    at least Sqrt merged in
    math/big, but not right now, it's not tested enough).

    Il giorno martedì 1 marzo 2016 21:39:12 UTC+1, Owen Waller ha scritto:

    Hi,

    I find myself trying to covert some Python code to Go which
    uses arbitrary large numbers.
    The original Python code takes the square root and floors the
    result of one of these numbers.

    But, looking at Go's math/big package, I can't work out how
    square root one of these numbers. There doesn't, at first
    glance, seem to be an arbitrary "pow" function. Likewise the
    floor function.

    As this isn't my usual area, I feel don't understanding
    something fundamental. Does anyone have any pointers, or
    packages, or example code that can point me in the right
    direction?

    Thanks

    Owen

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Alb Donizetti at Mar 1, 2016 at 11:43 pm
    I think it would be nice to have Sqrt, Pow, Log and Exp in math/big.
    Everything
    else is probably not worth it (at least not in the standard library).

    Il giorno mercoledì 2 marzo 2016 00:34:23 UTC+1, Owen Waller ha scritto:
    Ah ha. Thank you very much Alberto. This should get me a lot further.

    On a more general point. Given that you have written this, is math/big
    might lacking some more functions. Do you, or anyone else, have an list of
    functions that should be added?

    This isn't my area by any means, but if it scratches an itch, I'll offer
    to help.

    Owen

    On Tue, 2016-03-01 at 15:11 -0800, alb.do...@gmail.com <javascript:>
    wrote:

    For floor you have to use Float.Int() (
    https://golang.org/pkg/math/big/#Float.Int)

    I have Sqrt, Log and Pow implementations here:
    https://godoc.org/github.com/ALTree/floatutils

    DISCLAIMER: I don't guarantee correctness of the last decimal digit

    It's not a real library, more like a few experiments (I'd like to see at
    least Sqrt merged in
    math/big, but not right now, it's not tested enough).

    Il giorno martedì 1 marzo 2016 21:39:12 UTC+1, Owen Waller ha scritto:

    Hi,

    I find myself trying to covert some Python code to Go which uses arbitrary
    large numbers.
    The original Python code takes the square root and floors the result of
    one of these numbers.

    But, looking at Go's math/big package, I can't work out how square root
    one of these numbers. There doesn't, at first glance, seem to be an
    arbitrary "pow" function. Likewise the floor function.

    As this isn't my usual area, I feel don't understanding something
    fundamental. Does anyone have any pointers, or packages, or example code
    that can point me in the right direction?

    Thanks

    Owen

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Keith Randall at Mar 1, 2016 at 11:54 pm
    math/big.Exp is the equivalent of math.Pow.
    I'm not sure why you would want math.Exp (e^x) or math.Log (log_e) in an
    integer library.
    math/big.BitLen is approximately math.Log2.
    On Tuesday, March 1, 2016 at 3:43:24 PM UTC-8, alb.do...@gmail.com wrote:

    I think it would be nice to have Sqrt, Pow, Log and Exp in math/big.
    Everything
    else is probably not worth it (at least not in the standard library).

    Il giorno mercoledì 2 marzo 2016 00:34:23 UTC+1, Owen Waller ha scritto:
    Ah ha. Thank you very much Alberto. This should get me a lot further.

    On a more general point. Given that you have written this, is math/big
    might lacking some more functions. Do you, or anyone else, have an list of
    functions that should be added?

    This isn't my area by any means, but if it scratches an itch, I'll offer
    to help.

    Owen

    On Tue, 2016-03-01 at 15:11 -0800, alb.do...@gmail.com wrote:

    For floor you have to use Float.Int() (
    https://golang.org/pkg/math/big/#Float.Int)

    I have Sqrt, Log and Pow implementations here:
    https://godoc.org/github.com/ALTree/floatutils

    DISCLAIMER: I don't guarantee correctness of the last decimal digit

    It's not a real library, more like a few experiments (I'd like to see at
    least Sqrt merged in
    math/big, but not right now, it's not tested enough).

    Il giorno martedì 1 marzo 2016 21:39:12 UTC+1, Owen Waller ha scritto:

    Hi,

    I find myself trying to covert some Python code to Go which uses
    arbitrary large numbers.
    The original Python code takes the square root and floors the result of
    one of these numbers.

    But, looking at Go's math/big package, I can't work out how square root
    one of these numbers. There doesn't, at first glance, seem to be an
    arbitrary "pow" function. Likewise the floor function.

    As this isn't my usual area, I feel don't understanding something
    fundamental. Does anyone have any pointers, or packages, or example code
    that can point me in the right direction?

    Thanks

    Owen

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Alb Donizetti at Mar 1, 2016 at 11:59 pm
    Hi Keith,

    we are talking about multi-precision floats (big.Float) not multi-precision
    ints (big.Int) : )

    Il giorno mercoledì 2 marzo 2016 00:54:43 UTC+1, Keith Randall ha scritto:
    math/big.Exp is the equivalent of math.Pow.
    I'm not sure why you would want math.Exp (e^x) or math.Log (log_e) in an
    integer library.
    math/big.BitLen is approximately math.Log2.
    On Tuesday, March 1, 2016 at 3:43:24 PM UTC-8, alb.do...@gmail.com wrote:

    I think it would be nice to have Sqrt, Pow, Log and Exp in math/big.
    Everything
    else is probably not worth it (at least not in the standard library).

    Il giorno mercoledì 2 marzo 2016 00:34:23 UTC+1, Owen Waller ha scritto:
    Ah ha. Thank you very much Alberto. This should get me a lot further.

    On a more general point. Given that you have written this, is math/big
    might lacking some more functions. Do you, or anyone else, have an list of
    functions that should be added?

    This isn't my area by any means, but if it scratches an itch, I'll offer
    to help.

    Owen

    On Tue, 2016-03-01 at 15:11 -0800, alb.do...@gmail.com wrote:

    For floor you have to use Float.Int() (
    https://golang.org/pkg/math/big/#Float.Int)

    I have Sqrt, Log and Pow implementations here:
    https://godoc.org/github.com/ALTree/floatutils

    DISCLAIMER: I don't guarantee correctness of the last decimal digit

    It's not a real library, more like a few experiments (I'd like to see at
    least Sqrt merged in
    math/big, but not right now, it's not tested enough).

    Il giorno martedì 1 marzo 2016 21:39:12 UTC+1, Owen Waller ha scritto:

    Hi,

    I find myself trying to covert some Python code to Go which uses
    arbitrary large numbers.
    The original Python code takes the square root and floors the result of
    one of these numbers.

    But, looking at Go's math/big package, I can't work out how square root
    one of these numbers. There doesn't, at first glance, seem to be an
    arbitrary "pow" function. Likewise the floor function.

    As this isn't my usual area, I feel don't understanding something
    fundamental. Does anyone have any pointers, or packages, or example code
    that can point me in the right direction?

    Thanks

    Owen

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rob Pike at Mar 2, 2016 at 12:49 am
    Ivy (github.com/robpike/ivy) has implementations of these functions, but
    they are not ideally wrapped for general use. I apologize for putting
    words in his mouth, but I believe Robert Griesemer has been thinking about
    adding some transcendentals to math/big, or more likely a separate library.

    See https://github.com/golang/go/issues/14102

    -rob

    On Wed, Mar 2, 2016 at 10:59 AM, wrote:

    Hi Keith,

    we are talking about multi-precision floats (big.Float) not
    multi-precision ints (big.Int) : )


    Il giorno mercoledì 2 marzo 2016 00:54:43 UTC+1, Keith Randall ha scritto:
    math/big.Exp is the equivalent of math.Pow.
    I'm not sure why you would want math.Exp (e^x) or math.Log (log_e) in an
    integer library.
    math/big.BitLen is approximately math.Log2.
    On Tuesday, March 1, 2016 at 3:43:24 PM UTC-8, alb.do...@gmail.com wrote:

    I think it would be nice to have Sqrt, Pow, Log and Exp in math/big.
    Everything
    else is probably not worth it (at least not in the standard library).

    Il giorno mercoledì 2 marzo 2016 00:34:23 UTC+1, Owen Waller ha scritto:
    Ah ha. Thank you very much Alberto. This should get me a lot further.

    On a more general point. Given that you have written this, is math/big
    might lacking some more functions. Do you, or anyone else, have an list of
    functions that should be added?

    This isn't my area by any means, but if it scratches an itch, I'll
    offer to help.

    Owen

    On Tue, 2016-03-01 at 15:11 -0800, alb.do...@gmail.com wrote:

    For floor you have to use Float.Int() (
    https://golang.org/pkg/math/big/#Float.Int)

    I have Sqrt, Log and Pow implementations here:
    https://godoc.org/github.com/ALTree/floatutils

    DISCLAIMER: I don't guarantee correctness of the last decimal digit

    It's not a real library, more like a few experiments (I'd like to see
    at least Sqrt merged in
    math/big, but not right now, it's not tested enough).

    Il giorno martedì 1 marzo 2016 21:39:12 UTC+1, Owen Waller ha scritto:

    Hi,

    I find myself trying to covert some Python code to Go which uses
    arbitrary large numbers.
    The original Python code takes the square root and floors the result of
    one of these numbers.

    But, looking at Go's math/big package, I can't work out how square root
    one of these numbers. There doesn't, at first glance, seem to be an
    arbitrary "pow" function. Likewise the floor function.

    As this isn't my usual area, I feel don't understanding something
    fundamental. Does anyone have any pointers, or packages, or example code
    that can point me in the right direction?

    Thanks

    Owen

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Owen Waller at Mar 3, 2016 at 12:05 am
    Many thanks for pointing me towards Ivy and the github issue. Both very
    helpful.

    If we could have this support added to math/big or as a new package in
    the Go 1.7 timeframe that would be fantastic.

    Owen
    On Wed, 2016-03-02 at 11:48 +1100, Rob Pike wrote:
    Ivy (github.com/robpike/ivy) has implementations of these functions,
    but they are not ideally wrapped for general use. I apologize for
    putting words in his mouth, but I believe Robert Griesemer has been
    thinking about adding some transcendentals to math/big, or more likely
    a separate library.



    See https://github.com/golang/go/issues/14102



    -rob




    On Wed, Mar 2, 2016 at 10:59 AM, wrote:

    Hi Keith,

    we are talking about multi-precision floats (big.Float) not
    multi-precision ints (big.Int) : )



    Il giorno mercoledì 2 marzo 2016 00:54:43 UTC+1, Keith Randall
    ha scritto:

    math/big.Exp is the equivalent of math.Pow.

    I'm not sure why you would want math.Exp (e^x) or
    math.Log (log_e) in an integer library.

    math/big.BitLen is approximately math.Log2.



    On Tuesday, March 1, 2016 at 3:43:24 PM UTC-8,
    alb.do...@gmail.com wrote:

    I think it would be nice to have Sqrt, Pow,
    Log and Exp in math/big. Everything
    else is probably not worth it (at least not in
    the standard library).

    Il giorno mercoledì 2 marzo 2016 00:34:23 UTC
    +1, Owen Waller ha scritto:

    Ah ha. Thank you very much Alberto.
    This should get me a lot further.

    On a more general point. Given that
    you have written this, is math/big
    might lacking some more functions. Do
    you, or anyone else, have an list of
    functions that should be added?

    This isn't my area by any means, but
    if it scratches an itch, I'll offer to
    help.

    Owen

    On Tue, 2016-03-01 at 15:11 -0800,
    alb.do...@gmail.com wrote:
    For floor you have to use
    Float.Int()
    (https://golang.org/pkg/math/big/#Float.Int)

    I have Sqrt, Log and Pow
    implementations here:
    https://godoc.org/github.com/ALTree/floatutils

    DISCLAIMER: I don't guarantee
    correctness of the last decimal
    digit

    It's not a real library, more like a
    few experiments (I'd like to see at
    least Sqrt merged in
    math/big, but not right now, it's
    not tested enough).

    Il giorno martedì 1 marzo 2016
    21:39:12 UTC+1, Owen Waller ha
    scritto:

    Hi,

    I find myself trying to
    covert some Python code to
    Go which uses arbitrary
    large numbers.
    The original Python code
    takes the square root and
    floors the result of one of
    these numbers.

    But, looking at Go's
    math/big package, I can't
    work out how square root one
    of these numbers. There
    doesn't, at first glance,
    seem to be an arbitrary
    "pow" function. Likewise the
    floor function.

    As this isn't my usual area,
    I feel don't understanding
    something fundamental. Does
    anyone have any pointers, or
    packages, or example code
    that can point me in the
    right direction?

    Thanks

    Owen

    --
    You received this message because
    you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and
    stop receiving emails from it, send
    an email to
    golang-nuts...@googlegroups.com.
    For more options, visit
    https://groups.google.com/d/optout.




    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 1, '16 at 8:38p
activeMar 3, '16 at 12:05a
posts9
users5
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase