Index: trunk/Include/basic/function.sbp
===================================================================
--- trunk/Include/basic/function.sbp	(revision 385)
+++ trunk/Include/basic/function.sbp	(revision 388)
@@ -78,19 +78,15 @@
 
 Function pow(x As Double, y As Double) As Double
-	If -LONG_MAX<=y and y<=LONG_MAX and y=CDbl(Int(y)) Then
-		pow=ipow(x,y As Long)
+'	If -LONG_MAX<=y and y<=LONG_MAX and y=CDbl(Int(y)) Then
+	If y = (y As Long) Then
+		pow = ipow(x, y As Long)
+	ElseIf x>0 Then
+		pow = Exp(y * Log(x))
 		Exit Function
-	End If
-
-	If x>0 Then
-		pow=Exp(y*Log(x))
-		Exit Function
-	End If
-
-	If x<>0 or y<=0 Then
-		'error
-	End If
-
-	pow=0
+	ElseIf x<>0 or y<=0 Then
+		pow = ActiveBasic.Math.Detail.GetNaN()
+	Else
+		pow = 0
+	End If
 End Function
 
@@ -272,5 +268,5 @@
 		Return New String(c As StrChar, 1)
 	ElseIf c < &h10FFFF Then
-		Dim t[1] = [&hD800 Or (c >> 10), &hDC00 Or (c And &h3FF)] As StrChar
+		Dim t[1] = [&hD800 Or (c >> 10), &hDC00 Or (c And &h3FF)] As WCHAR
 		Return New String(t, 2)
 	Else
@@ -306,36 +302,12 @@
 End Function
 
-Dim _System_HexadecimalTable[&h10] = [&h30, &h31, &h32, &h33, &h34, &h35, &h36, &h37, &h38, &h39, &h41, &h42, &h43, &h44, &h45, &h46] As Byte
-
-Function _System_Hex(x As DWord, zeroSuppress As Boolean) As String
-	Dim s[7] As StrChar
-	Dim i As Long
-	For i = 0 To ELM(Len (s) \ SizeOf (StrChar))
-		s[i] = _System_HexadecimalTable[x >> 28] As StrChar
-		x <<= 4
-	Next
-	If zeroSuppress Then
-		Dim i As Long
-		For i = 0 To 6
-			If s[i] <> &h30 Then 'Asc("0")
-				Exit For
-			End If
-		Next
-		Return New String(VarPtr(s[i]) As *StrChar, Len (s) \ SizeOf (StrChar) - i)
-	Else
-		Return New String(s As *StrChar, Len (s) \ SizeOf (StrChar))
-	End If
-End Function
-
 Function Hex$(x As DWord) As String
-	Hex$ = _System_Hex(x, True)
+	Imports ActiveBasic.Strings.Detail
+	Hex$ = FormatIntegerX(x, 1, 0, None)
 End Function
 
 Function Hex$(x As QWord) As String
-	If HIDWORD(x) = 0 Then
-		Hex$ = _System_Hex(LODWORD(x), True)
-	Else
-		Hex$ = _System_Hex(HIDWORD(x), True) + _System_Hex(LODWORD(x), False)
-	End If
+	Imports ActiveBasic.Strings.Detail
+	Hex$ = FormatIntegerLX(x, 1, 0, None)
 End Function
 
@@ -391,30 +363,12 @@
 End Function
 
-Const _System_MaxFigure_Oct_QW = 22 As DWord 'QWORD_MAX = &o1,777,777,777,777,777,777,777
 Function Oct$(n As QWord) As String
-	Dim s[ELM(_System_MaxFigure_Oct_QW)] As StrChar
-	Dim i = ELM(_System_MaxFigure_Oct_QW) As Long
-	Do
-		s[i] = ((n And &o7) + &h30) As StrChar '&h30 = Asc("0")
-		n >>= 3
-		If n = 0 Then
-			Return New String(s + i, _System_MaxFigure_Oct_QW - i)
-		End If
-		i--
-	Loop
-End Function
-
-Const _System_MaxFigure_Oct_DW = 11 As DWord 'DWORD_MAX = &o37,777,777,777
+	Imports ActiveBasic.Strings.Detail
+	Oct$ = FormatIntegerLO(n, 1, 0, None)
+End Function
+
 Function Oct$(n As DWord) As String
-	Dim s[ELM(_System_MaxFigure_Oct_DW)] As StrChar
-	Dim i = ELM(_System_MaxFigure_Oct_DW) As Long
-	Do
-		s[i] = ((n And &o7) + &h30) As StrChar '&h30 = Asc("0")
-		n >>= 3
-		If n = 0 Then
-			Return New String(s + i, _System_MaxFigure_Oct_DW - i)
-		End If
-		i--
-	Loop
+	Imports ActiveBasic.Strings.Detail
+	Oct$ = FormatIntegerO(n, 1, 0, None)
 End Function
 
@@ -493,7 +447,9 @@
 
 Function Str$(dbl As Double) As String
-	If ActiveBasic.Math.IsNaN(dbl) Then
+	Imports ActiveBasic.Math
+	Imports ActiveBasic.Strings
+	If IsNaN(dbl) Then
 		Return "NaN"
-	ElseIf ActiveBasic.Math.IsInf(dbl) Then
+	ElseIf IsInf(dbl) Then
 		If dbl > 0 Then
 			Return "Infinity"
@@ -521,8 +477,8 @@
 		buffer[i] = Asc(".")
 		i++
-		ActiveBasic.Strings.ChrCopy(VarPtr(buffer[i]), VarPtr(temp[1]), 14 As SIZE_T)
+		ChrCopy(VarPtr(buffer[i]), VarPtr(temp[1]), 14 As SIZE_T)
 		i += 14
 		buffer[i] = 0
-		Return MakeStr(buffer) + ActiveBasic.Strings.SPrintf("e%+03d", New System.Int32(dec - 1))
+		Return MakeStr(buffer) + SPrintf("e%+03d", New System.Int32(dec - 1))
 	End If
 
@@ -637,5 +593,5 @@
 	If String.IsNullOrEmpty(s) Then
 		Return New String(0 As StrChar, n)
-			Else
+	Else
 		Return New String(s[0], n)
 	End If
@@ -971,5 +927,5 @@
 
 /*!
-@brief	ABオブジェクトを指すポインタをObject型へ変換。
+@brief	ObjPtrの逆。ABオブジェクトを指すポインタをObject型へ変換。
 @author	Egtra
 @date	2007/08/24
@@ -1012,44 +968,4 @@
 End Function
 
-Function _System_ASCII_IsUpper(c As WCHAR) As Boolean
-	Return c As DWord - &h41 < 26 ' &h41 = Asc("A")
-End Function
-
-Function _System_ASCII_IsUpper(c As SByte) As Boolean
-	Return _System_ASCII_IsUpper(c As Byte As WCHAR)
-End Function
-
-Function _System_ASCII_IsLower(c As WCHAR) As Boolean
-	Return c As DWord - &h61 < 26 ' &h61 = Asc("a")
-End Function
-
-Function _System_ASCII_IsLower(c As SByte) As Boolean
-	Return _System_ASCII_IsLower(c As Byte As WCHAR)
-End Function
-
-Function _System_ASCII_ToLower(c As WCHAR) As WCHAR
-	If _System_ASCII_IsUpper(c) Then
-		Return c Or &h20
-	Else
-		Return c
-	End If
-End Function
-
-Function _System_ASCII_ToLower(c As SByte) As SByte
-	Return _System_ASCII_ToLower(c As Byte As WCHAR) As Byte As SByte
-End Function
-
-Function _System_ASCII_ToUpper(c As WCHAR) As WCHAR
-	If _System_ASCII_IsLower(c) Then
-		Return c And (Not &h20)
-	Else
-		Return c
-	End If
-End Function
-
-Function _System_ASCII_ToUpper(c As SByte) As SByte
-	Return _System_ASCII_ToUpper(c As Byte As WCHAR) As Byte As SByte
-End Function
-
 Function _System_GetHashFromWordArray(p As *Word, n As SIZE_T) As Long
 	Dim hash = 0 As DWord
