Skip to content

Commit

Permalink
Update main.c
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Mathur <[email protected]>
  • Loading branch information
Harsh-Mathur-1503 authored Nov 12, 2024
1 parent ef7a4c9 commit 99acace
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,26 @@
* // returns 42.0f
*/
float stdlib_base_lcmf( const float a, const float b ) {
float abs_a;
float abs_b;
float gcd_value;
double abs_a;
double abs_b;
double gcd_value;
const double b = 1.0;

if(a==0.0||b==0.0){
if ( a == 0.0 || b == 0.0 ) {
return 0.0;
}
if(a<0.0){
abs_a=-a;
}else{
abs_a=a;
if ( a < 0.0 ) {
abs_a = -a;
} else {
abs_a = a;
}
if(b<0.0){
abs_b=-b;
}else{
abs_b=b;
if ( b < 0.0 ) {
abs_b = -b;
} else {
abs_b = b;
}

abs_a=(a<0.0f)?-a:a;
abs_b=(b<0.0f)?-b:b;

// Note: we rely on `gcd` to perform further argument validation...
gcd_value=stdlib_base_gcd(abs_a,abs_b);

if(stdlib_base_is_nan(gcd_value)){
return gcd_value;
}
Expand Down

0 comments on commit 99acace

Please sign in to comment.