home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.arch      Apparently more than just beeps & boops      131,241 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 130,536 of 131,241   
   BGB to Thomas Koenig   
   Re: Lessons from the ARM Architecture   
   17 Dec 25 03:03:04   
   
   From: cr88192@gmail.com   
      
   On 12/17/2025 1:59 AM, Thomas Koenig wrote:   
   > BGB  schrieb:   
   >   
   >> double sin(double ang)   
   >> {   
   >> 	double t, x, th, th2;   
   >> 	int i;   
   >> 	i=ang*M_TAU_R;   
   >> 	th=ang-(i*M_TAU);   
   >> 	th2=th*th;   
   >   
   > That leaves a lot of room for improvement; you would be better   
   > off reducing to [-pi/4,+pi/4].  See   
   > https://userpages.cs.umbc.edu/phatak/645/supl/Ng-ArgReduction.pdf   
   > for a random reference grabbed off the net how to do it.   
   >   
      
   Possible, I didn't evaluate this.   
      
   I just sorta reduced it to [0, 2*PI] noting that if values got too far   
   outside of this range, accuracy started dropping off, so limiting to   
   this range kept the accuracy good.   
      
   Though, it flips to [-2*PI, 0] if ang<0, since conversion to 'int'   
   truncates towards zero and not towards negative infinity. Not entirely   
   sure why I used 'int' and not 'long', possible oversight here...   
      
      
   > [...]   
   >   
   >> Time cost: roughly 450 clock cycles (penalties are steep on this one).   
   >   
   > What is your accuracy?   
      
      
   IIRC, I used 20 stages because this seemed to fully converge the double   
   to about as accurate as it was going to get in my initial testing   
   (without adding too many extra stages).   
      
   IIRC, basic algo was based on the Taylor Series expansion off of   
   Wikipedia or similar (I didn't show the magic constants).   
      
      
   It was also still a vast improvement over the code that the C library   
   originally came with (IIRC, used a "for()" look and calculated the   
   factorials and did the division inline; this was far slower than using   
   precomputed constants).   
      
      
   For "long double", it is both slower to calculate and also requires more   
   stages to converge the result.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca