Results 1 to 6 of 6

Thread: Taking large floating input

  1. #1
    Join Date
    Jul 2007
    Location
    India
    Beans
    449

    Taking large floating input

    When taking large floating input(eg:2.99999999999999999999). Python converts it to 3.0

    How do i avoid such conversion, so that i get 2.99999999... as the value stored.

  2. #2
    WW is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Oct 2004
    Beans
    1,532

    Re: Taking large floating input

    Floating point numbers in python are finite precision. If you really need arbitrary precision, libraries such as mpmath are available.

  3. #3
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Taking large floating input

    Look at the decimal module (class Decimal) for fixed point.
    LambdaGrok. | #ubuntu-programming on FreeNode

  4. #4
    Join Date
    Jul 2007
    Beans
    93
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Taking large floating input

    There are string based libraries in C++ and java for handling arbitrarily large numbers, you should see if they exist for python.

  5. #5
    Join Date
    Nov 2006
    Location
    Philadelphia, PA
    Beans
    Hidden!

    Re: Taking large floating input

    Quote Originally Posted by rharriso View Post
    There are string based libraries in C++ and java for handling arbitrarily large numbers, you should see if they exist for python.
    BigDecimal?
    ThinkPad R61 14" | Fedora 14 | Core 2 Duo 2.0Ghz | 4GB DDR2 | 64GB SSD

  6. #6
    Join Date
    Feb 2009
    Beans
    202

    Re: Taking large floating input

    Quote Originally Posted by kavon89 View Post
    BigDecimal?
    Sounds what I used when I needed really BIG numbers for cryptograph program.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •