Thread: mathematic instruction using random

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    87

    mathematic instruction using random

    Hi,
    i have some mathematic instruction to resolve
    |z - c| =< r and|z - w| =< d
    because i want just one number , i used randomise
    Code:
     mini =min((d-w),(c-r));
    
       maxi=max((d+w),(r+c));
       
       z=mini + (rand()%(maxii - minii));
    it give me ranom number but when i use it to calculate another
    Code:
    f=sqrt(pow(d,2)-pow((z-w),2));
    it give me error because many times the "z"is very hight
    so i get negative inter the sqrt
    how i resolve this problem ? shall i add another limit to the Z?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Why do you have both maxi and maxii? What's the value of maxii?

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    87
    Quote Originally Posted by tabstop View Post
    Why do you have both maxi and maxii? What's the value of maxii?
    oups , i made error , it's the same maxii=maxi

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So if I understand you right, if r+c > d+w you don't want to go as high as r+c, because that would make |z-w| > d. So you would in fact want the smaller of those two numbers....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. arm assembley instruction BAL
    By c_weed in forum Tech Board
    Replies: 2
    Last Post: 10-16-2011, 02:38 AM
  2. Meaning of the instruction >>=
    By frodo_jedi in forum C Programming
    Replies: 4
    Last Post: 05-07-2009, 07:57 AM
  3. x86 Instruction SBB
    By Aleck_pl in forum C Programming
    Replies: 6
    Last Post: 04-10-2009, 04:43 PM
  4. Mathematic issue
    By XZminX in forum C Programming
    Replies: 4
    Last Post: 03-31-2005, 11:23 AM
  5. ASM with MOV instruction.
    By kinghajj in forum Tech Board
    Replies: 6
    Last Post: 10-14-2003, 12:41 AM