コード例 #1
0
ファイル: ext_bcmath.cpp プロジェクト: Neomeng/hiphop-php
Variant f_bcsqrt(CStrRef operand, int64 scale /* = -1 */) {
  if (scale < 0) scale = BCG(bc_precision);
  bc_num result;
  bc_init_num(&result);
  php_str2num(&result, (char*)operand.data());
  Variant ret;
  if (bc_sqrt(&result, scale) != 0) {
    if (result->n_scale > scale) {
      result->n_scale = scale;
    }
    ret = String(bc_num2str(result), AttachString);
  } else {
    Logger::Warning("Square root of negative number");
  }
  bc_free_num(&result);
  return ret;
}
コード例 #2
0
ファイル: ext_bcmath.cpp プロジェクト: Einkoro/hhvm
static Variant HHVM_FUNCTION(bcsqrt, const String& operand,
                             int64_t scale /* = -1 */) {
  if (scale < 0) scale = BCG(bc_precision);
  bc_num result;
  bc_init_num(&result);
  php_str2num(&result, (char*)operand.data());
  Variant ret;
  if (bc_sqrt(&result, scale) != 0) {
    if (result->n_scale > scale) {
      result->n_scale = scale;
    }
    ret = String(bc_num2str(result), AttachString);
  } else {
    raise_warning("Square root of negative number");
  }
  bc_free_num(&result);
  return ret;
}
コード例 #3
0
ファイル: BigNumber.cpp プロジェクト: flok99/BigNumber
// square root
BigNumber BigNumber::sqrt () const
{
  BigNumber result (*this);
  bc_sqrt (&result.num_, scale_);
  return result;
} // end of BigNumber::sqrt