MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / Int128Mul

Function Int128Mul

TheForceEngine/TFE_Polygon/clipper.cpp:354–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352//------------------------------------------------------------------------------
353
354Int128 Int128Mul (long64 lhs, long64 rhs)
355{
356 bool negate = (lhs < 0) != (rhs < 0);
357
358 if (lhs < 0) lhs = -lhs;
359 ulong64 int1Hi = ulong64(lhs) >> 32;
360 ulong64 int1Lo = ulong64(lhs & 0xFFFFFFFF);
361
362 if (rhs < 0) rhs = -rhs;
363 ulong64 int2Hi = ulong64(rhs) >> 32;
364 ulong64 int2Lo = ulong64(rhs & 0xFFFFFFFF);
365
366 //nb: see comments in clipper.pas
367 ulong64 a = int1Hi * int2Hi;
368 ulong64 b = int1Lo * int2Lo;
369 ulong64 c = int1Hi * int2Lo + int1Lo * int2Hi;
370
371 Int128 tmp;
372 tmp.hi = long64(a + (c >> 32));
373 tmp.lo = long64(c << 32);
374 tmp.lo += long64(b);
375 if (tmp.lo < b) tmp.hi++;
376 if (negate) tmp = -tmp;
377 return tmp;
378};
379#endif
380
381//------------------------------------------------------------------------------

Callers 1

SlopesEqualFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected