I just want to know if this is too much code to be put on a ctor?
constexpr FFloat160::FFloat160(const int64 HiVal, const int64 LoVal, const int32 ExVal)
: Hi{HiVal}, Lo{LoVal}, Ex{ExVal}
{
// Lo can only be 0, if Hi is 0
if (Lo == 0LL && Hi != 0LL)
{
Lo = Hi;
Hi = 0LL;
Ex += 18;
}
// Make sure Hi and Lo sign is same
if ((Hi > 0LL && Lo < 0LL) || (Hi < 0LL && Lo > 0LL))
Lo *= -1LL;
// Make sure Lo don't have Trailing Zero
const int32 TrailingZeroNum = TaMath::CountTrailingZero(Lo);
if (TrailingZeroNum != 0)
{
const int64 ExpoDivisor = static_cast<int64>(FMath::Pow(10.0, TrailingZeroNum));
Lo /= ExpoDivisor;
if (Hi != 0LL)
{
Lo += (Hi % ExpoDivisor) * static_cast<int64>(FMath::Pow(10.0, 18 - TrailingZeroNum));
Hi /= ExpoDivisor;
}
Ex += TrailingZeroNum;
}
// if Hi have more than 18 digits
if (FMath::Abs(Hi) > 999'999'999'999'999'999LL)
{
Lo /= 10LL;
Lo += (Hi % 10LL) * 100'000'000'000'000'000LL;
Hi /= 10LL;
Ex += 1;
}
// if Lo have more than 18 digits
if (FMath::Abs(Lo) > 999'999'999'999'999'999LL)
{
Hi = Lo / 1000'000'000'000'000'000LL;
Lo %= 1000'000'000'000'000'000LL;
}
}