File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -68,16 +68,14 @@ library CurveLib {
6868            unchecked  {
6969                squaredB =  absB *  absB; // scale: 1e36 
7070                discriminant =  squaredB +  fourAC; // scale: 1e36 
71-                 sqrt =  Math.sqrt (discriminant); // scale: 1e18 
72-                 sqrt =  (sqrt *  sqrt <  discriminant) ?  sqrt +  1  :  sqrt;
71+                 sqrt =  Math.sqrt (discriminant, Math.Rounding.Ceil); // scale: 1e18 
7372            }
7473        } else  {
7574            // B^2 cannot be calculated directly at 1e18 scale without overflowing 
7675            uint256  scale =  computeScale (absB); // calculate the scaling factor such that B^2 can be calculated without overflowing 
7776            squaredB =  Math.mulDiv (absB /  scale, absB, scale, Math.Rounding.Ceil);
7877            discriminant =  squaredB +  fourAC /  (scale *  scale);
79-             sqrt =  Math.sqrt (discriminant);
80-             sqrt =  (sqrt *  sqrt <  discriminant) ?  sqrt +  1  :  sqrt;
78+             sqrt =  Math.sqrt (discriminant, Math.Rounding.Ceil);
8179            sqrt =  sqrt *  scale;
8280        }
8381
@@ -86,7 +84,7 @@ library CurveLib {
8684            // use the regular quadratic formula solution (-b + sqrt(b^2 - 4ac)) / 2a 
8785            x =  Math.mulDiv (absB +  sqrt, 1e18 , 2  *  c, Math.Rounding.Ceil) +  1 ;
8886        } else  {
89-             // use the "citardauq" quadratic formula solution 2c / (-b +  sqrt(b^2 - 4ac)) 
87+             // use the "citardauq" quadratic formula solution 2c / (-b -  sqrt(b^2 - 4ac)) 
9088            x =  (2  *  C +  (absB +  sqrt -  1 )) /  (absB +  sqrt) +  1 ;
9189        }
9290
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments