| 
上へ整数 → MegaLong
 実数 → MegaLong
 10進数 → MegaLong
 文字列 → MegaLong
 整数部分
 小数部分
 部分値
 MegaLong → Long
 MegaLong → Double
 文字列変換
 |  | 
  
    | 数値変換 |  
    | 整数部分(IntegrPart) |  
    | 最終更新日:2007/02/20 新規 |  ●概要  MegaLong の整数部分をMegaLong として取り出す。 ●方法 
  IntegerPart = Me.Copy Me は、元のMegaLong
 IntegerPart は、整数を表す新しいMegaLong で、取りあえずコピーしておく。
Zero のときは、Zero。Overflow、NaN の場合は、その通りを返す。Exp ≧ Length であれば、これは元々整数なので、そのままを返す。Exp < Length の場合は、小数部が存在するので以下のように小数部をカットする。(下図の例参照)
 
 Dim Ix As Integer = (Me.Exp - 1) \ 8            
  '整数部末尾の要素番号
 Dim L As Integer = (Me.Exp - 1) Mod 8        
  '1の位の桁番号
 ReDim Preserve IntegerPart.Mant(Ix)          
  '不要な小数用要素を除去
 If L < 7 Then
 IntegerPart.Mant(Ix) = (IntegerPart.Mant(Ix) \ NormT(L)) * 
  NormT(L)
 'この演算で、余計な小数桁を0 にしている
 End If
 IntegerPart.Length = Me.Exp      '有効桁数
 
   |