diff options
| author | Ethan Werner <mail@ethanwerner.com> | 2026-08-09 15:02:21 +0400 |
|---|---|---|
| committer | Ethan Werner <mail@ethanwerner.com> | 2026-08-09 15:02:21 +0400 |
| commit | 3d92926a902017e7cf1f5738e99ff62da596ce12 (patch) | |
| tree | 2b55422c26a48759d56fa91f06df24449e9dfa88 /lib/lcm.c | |
| parent | 07e18043145f3d91c8ea7ec3ad41b3c905585277 (diff) | |
Diffstat (limited to 'lib/lcm.c')
| -rw-r--r-- | lib/lcm.c | 52 |
1 files changed, 28 insertions, 24 deletions
@@ -31,30 +31,34 @@ int ts_lcm( { TS_PROLOGUE( ts_lcm_p ); (void)c; - for( uint_t i = 0; i < n; ++i ) - { - fp_t ax = fabs(x[0][i]); - fp_t bx = fabs(x[1][i]); - if (ax > 1e15 || bx > 1e15) { y[0][i] = 0.0; continue; } - long a = (long)ax; - long b = (long)bx; - if( !a || !b ) - { - y[0][i] = 0.0; - } - else - { - long ta = a; - long tb = b; - while( tb ) - { - long t = tb; - tb = ta % tb; - ta = t; - } - y[0][i] = (fp_t)(a / ta) * (fp_t)b; - } - } + for( uint_t i = 0; i < n; ++i ) + { + fp_t ax = fabs(x[0][i]); + fp_t bx = fabs(x[1][i]); + if (ax > 9223372036854775807.0 || bx > 9223372036854775807.0) + { + y[0][i] = 0.0; + continue; + } + long a = (long)ax; + long b = (long)bx; + if( !a || !b ) + { + y[0][i] = 0.0; + } + else + { + long ta = a; + long tb = b; + while( tb ) + { + long t = tb; + tb = ta % tb; + ta = t; + } + y[0][i] = (fp_t)(a / ta) * (fp_t)b; + } + } return 0; } |