1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Split a/(b+c)

  1. May 26, 2010 #1
    let's say a/b = a/(b'+c)
    where b = b'+c.
    I need to separate the RHS into a/b' + something. What's that something?
     
  2. jcsd
  3. May 26, 2010 #2

    berkeman

    User Avatar

    Staff: Mentor

    What's the context? Is it just algebraic manipulation?

    Something = a/(b'+c) - a/b'

    and put over a common denominator?
     
  4. May 26, 2010 #3
    I need to convert x (ranging between 0 - 1,000,000) to y (ranging between 0 - (2^32)-1).

    so y = (x * 2^32)/1M => (x << 32)/ 1M

    We, the software guys have no problem doing it. But the microcode group says they don't have division operation.
    I was trying to provide a solution by converting (x << 32)/ 1M to (x <<32) / ((2^20) + a)
    (2^20 is the closest approximation to 1M)

    I need to measure the error I'm introducing if I assume a=0.
    If possible, I want to come up with a calculation as
    (x<<32) /((2^20) + a) => (x << 12) + b.
    What is b?
     
  5. May 26, 2010 #4

    berkeman

    User Avatar

    Staff: Mentor

    Do they have a multiply? Just multiply x * 4295

    Will that work?
     
  6. May 26, 2010 #5
    They have multiply operation for integers. Is it possible to make the approximation independent of x? We can use if-then-else.
     
  7. May 26, 2010 #6

    berkeman

    User Avatar

    Staff: Mentor

    Not sure what you mean by approximation. That multiplicative factor is pretty exact for doing the scaling that you asked about. Nice integer multiplication...
     
  8. May 26, 2010 #7
    1000000*4295 = 0x1 0000 7FC0
    1000000*4294 = 0x0 FFF1 3D80
    1000000*1125899906 >> 18 = 4294967292 (0x0 FFFF FFFC)
    1000000*2251799813 >> 19 = 4294967294 (0x0 FFFF FFFE)
     
    Last edited: May 26, 2010
  9. May 26, 2010 #8
    2^32 / 1M = 4,294.967296
    We rounded 4,294.967296... to 4295.

    So, for higher values of x, the deviation would be high.
     
  10. May 26, 2010 #9
    Thanks Berkeman and Xitami for your answers. Xitami's equation gives pretty accurate results.

    Xitami, can you tell how you derived that equation?
     
  11. May 27, 2010 #10
    Code (Text):
    PARI/GP >[B]{
    K=2^32-1;
    T=1000000;
    m=K/T;
    for(i=0,20,
            n=T*truncate(m*2^i)>>i;
            print(i" "K-n))}[/B]
    0 967295
    1 467295
    2 217295
    3 92295
    4 29795
    5 29795
    6 14170
    7 6358
    8 2452
    9 499
    10 499
    11 10
    12 10
    13 10
    14 10
    15 10
    16 10
    17 3
    18 3
    19 1
    20 1
    PARI/GP > [B]truncate(m*2^19)[/B]
    %2 = 2251799813
    PARI/GP > [B]#binary(truncate(m*2^19)*1000000)[/B]
    %3 = 51
    51 bits of intermediate result
     
    Last edited: May 27, 2010
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Split a/(b+c)
  1. AC sin (B/C) = B (Replies: 2)

Loading...