Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2007
    Posts
    2

    Unanswered: Large numbers! Need help,quickly.

    I have problem. I need to do a multiplication of to large numbers(about 150 digits). But I don't know which way I could do it. Could you help me?
    Thanx for help.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Never, say "never".
    AFAIK, Oracle can not handle 150 digits.
    All I can say is that any such requirement is totally daft & smells like a homework assignment.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Oct 2007
    Posts
    2
    I know that there is no such dataType. So I ask you, how I can solve this problem.
    Now I've done this with varchar typeand dividing it by char and then converting it to number. But I don't like this way.. I this there could be better way

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Since Oracle's NUMBER datatype cannot handle 150 digit numbers, I don't see how you can do better than using the VARCHAR method you apparently already have. Why doesn't Oracle support 150-digit numbers? Because they are of no practical use to 99.999% of its users! You apparently represent the 0.001% who could find a use for them.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    why not use FLOAT

    the answer that you get by multiplying two 150-digit numbers is so gargantuan that FLOAT will be close enough for any real world application

    i agree, this smells like homework (especially the "need help quickly" part -- sounds like it's due on monday)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >why not use FLOAT
    HUH?
    from http://download.oracle.com/docs/cd/B...1.htm#sthref80

    Code:
    NUMBER Datatype 
    The NUMBER datatype stores zero as well as positive and negative fixed numbers with absolute values from 1.0 x 10-130 to (but not including) 1.0 x 10126. If you specify an arithmetic expression whose value has an absolute value greater than or equal to 1.0 x 10126, then Oracle returns an error. Each NUMBER value requires from 1 to 22 bytes.
    
    Specify a fixed-point number using the following form:
    
    NUMBER(p,s)
    
    where:
    
    p is the precision, or the total number of significant decimal digits, where the most significant digit is the left-most nonzero digit, and the least significant digit is the right-most known digit. Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point.
    
    s is the scale, or the number of digits from the decimal point to the least significant digit. The scale can range from -84 to 127.
    
    Positive scale is the number of significant digits to the right of the decimal point to and including the least significant digit.
    
    Negative scale is the number of significant digits to the left of the decimal point, to but not including the least significant digit. For negative scale the least significant digit is on the left side of the decimal point, because the actual data is rounded to the specified number of places to the left of the decimal point. For example, a specification of (10,-2) means to round to hundreds.
    The SQL Standard can NOT handle 150 in neither scale nor precision!
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    no, but you can get really close!!

    for example, what is the percentage difference between the following two numbers:

    1)
    45,879,863,215,874,514,853,258,795,547,893,025,854 ,236,982,021,748,510,254,785,411,004,585,511,254,5 21,134

    2)
    4.587986321587451485325879554 * 10**79
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >no, but you can get really close!!
    "close" is a relative term.
    150-79=71
    if you consider a difference of 10**71 as being close, I want you as my banker & paying ME the difference between 10**79 and 10**150!

    BTW, I'd still would like to hear the Business justification for using/requiring a 150 digit number; regardless of where the decimal point is placed.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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