Changeset 388 for trunk/Include/basic/function.sbp
- Timestamp:
- Nov 25, 2007, 4:31:35 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/basic/function.sbp
r385 r388 78 78 79 79 Function pow(x As Double, y As Double) As Double 80 If -LONG_MAX<=y and y<=LONG_MAX and y=CDbl(Int(y)) Then 81 pow=ipow(x,y As Long) 80 ' If -LONG_MAX<=y and y<=LONG_MAX and y=CDbl(Int(y)) Then 81 If y = (y As Long) Then 82 pow = ipow(x, y As Long) 83 ElseIf x>0 Then 84 pow = Exp(y * Log(x)) 82 85 Exit Function 83 End If 84 85 If x>0 Then 86 pow=Exp(y*Log(x)) 87 Exit Function 88 End If 89 90 If x<>0 or y<=0 Then 91 'error 92 End If 93 94 pow=0 86 ElseIf x<>0 or y<=0 Then 87 pow = ActiveBasic.Math.Detail.GetNaN() 88 Else 89 pow = 0 90 End If 95 91 End Function 96 92 … … 272 268 Return New String(c As StrChar, 1) 273 269 ElseIf c < &h10FFFF Then 274 Dim t[1] = [&hD800 Or (c >> 10), &hDC00 Or (c And &h3FF)] As StrChar270 Dim t[1] = [&hD800 Or (c >> 10), &hDC00 Or (c And &h3FF)] As WCHAR 275 271 Return New String(t, 2) 276 272 Else … … 306 302 End Function 307 303 308 Dim _System_HexadecimalTable[&h10] = [&h30, &h31, &h32, &h33, &h34, &h35, &h36, &h37, &h38, &h39, &h41, &h42, &h43, &h44, &h45, &h46] As Byte309 310 Function _System_Hex(x As DWord, zeroSuppress As Boolean) As String311 Dim s[7] As StrChar312 Dim i As Long313 For i = 0 To ELM(Len (s) \ SizeOf (StrChar))314 s[i] = _System_HexadecimalTable[x >> 28] As StrChar315 x <<= 4316 Next317 If zeroSuppress Then318 Dim i As Long319 For i = 0 To 6320 If s[i] <> &h30 Then 'Asc("0")321 Exit For322 End If323 Next324 Return New String(VarPtr(s[i]) As *StrChar, Len (s) \ SizeOf (StrChar) - i)325 Else326 Return New String(s As *StrChar, Len (s) \ SizeOf (StrChar))327 End If328 End Function329 330 304 Function Hex$(x As DWord) As String 331 Hex$ = _System_Hex(x, True) 305 Imports ActiveBasic.Strings.Detail 306 Hex$ = FormatIntegerX(x, 1, 0, None) 332 307 End Function 333 308 334 309 Function Hex$(x As QWord) As String 335 If HIDWORD(x) = 0 Then 336 Hex$ = _System_Hex(LODWORD(x), True) 337 Else 338 Hex$ = _System_Hex(HIDWORD(x), True) + _System_Hex(LODWORD(x), False) 339 End If 310 Imports ActiveBasic.Strings.Detail 311 Hex$ = FormatIntegerLX(x, 1, 0, None) 340 312 End Function 341 313 … … 391 363 End Function 392 364 393 Const _System_MaxFigure_Oct_QW = 22 As DWord 'QWORD_MAX = &o1,777,777,777,777,777,777,777394 365 Function Oct$(n As QWord) As String 395 Dim s[ELM(_System_MaxFigure_Oct_QW)] As StrChar 396 Dim i = ELM(_System_MaxFigure_Oct_QW) As Long 397 Do 398 s[i] = ((n And &o7) + &h30) As StrChar '&h30 = Asc("0") 399 n >>= 3 400 If n = 0 Then 401 Return New String(s + i, _System_MaxFigure_Oct_QW - i) 402 End If 403 i-- 404 Loop 405 End Function 406 407 Const _System_MaxFigure_Oct_DW = 11 As DWord 'DWORD_MAX = &o37,777,777,777 366 Imports ActiveBasic.Strings.Detail 367 Oct$ = FormatIntegerLO(n, 1, 0, None) 368 End Function 369 408 370 Function Oct$(n As DWord) As String 409 Dim s[ELM(_System_MaxFigure_Oct_DW)] As StrChar 410 Dim i = ELM(_System_MaxFigure_Oct_DW) As Long 411 Do 412 s[i] = ((n And &o7) + &h30) As StrChar '&h30 = Asc("0") 413 n >>= 3 414 If n = 0 Then 415 Return New String(s + i, _System_MaxFigure_Oct_DW - i) 416 End If 417 i-- 418 Loop 371 Imports ActiveBasic.Strings.Detail 372 Oct$ = FormatIntegerO(n, 1, 0, None) 419 373 End Function 420 374 … … 493 447 494 448 Function Str$(dbl As Double) As String 495 If ActiveBasic.Math.IsNaN(dbl) Then 449 Imports ActiveBasic.Math 450 Imports ActiveBasic.Strings 451 If IsNaN(dbl) Then 496 452 Return "NaN" 497 ElseIf ActiveBasic.Math.IsInf(dbl) Then453 ElseIf IsInf(dbl) Then 498 454 If dbl > 0 Then 499 455 Return "Infinity" … … 521 477 buffer[i] = Asc(".") 522 478 i++ 523 ActiveBasic.Strings.ChrCopy(VarPtr(buffer[i]), VarPtr(temp[1]), 14 As SIZE_T)479 ChrCopy(VarPtr(buffer[i]), VarPtr(temp[1]), 14 As SIZE_T) 524 480 i += 14 525 481 buffer[i] = 0 526 Return MakeStr(buffer) + ActiveBasic.Strings.SPrintf("e%+03d", New System.Int32(dec - 1))482 Return MakeStr(buffer) + SPrintf("e%+03d", New System.Int32(dec - 1)) 527 483 End If 528 484 … … 637 593 If String.IsNullOrEmpty(s) Then 638 594 Return New String(0 As StrChar, n) 639 595 Else 640 596 Return New String(s[0], n) 641 597 End If … … 971 927 972 928 /*! 973 @brief ABオブジェクトを指すポインタをObject型へ変換。929 @brief ObjPtrの逆。ABオブジェクトを指すポインタをObject型へ変換。 974 930 @author Egtra 975 931 @date 2007/08/24 … … 1012 968 End Function 1013 969 1014 Function _System_ASCII_IsUpper(c As WCHAR) As Boolean1015 Return c As DWord - &h41 < 26 ' &h41 = Asc("A")1016 End Function1017 1018 Function _System_ASCII_IsUpper(c As SByte) As Boolean1019 Return _System_ASCII_IsUpper(c As Byte As WCHAR)1020 End Function1021 1022 Function _System_ASCII_IsLower(c As WCHAR) As Boolean1023 Return c As DWord - &h61 < 26 ' &h61 = Asc("a")1024 End Function1025 1026 Function _System_ASCII_IsLower(c As SByte) As Boolean1027 Return _System_ASCII_IsLower(c As Byte As WCHAR)1028 End Function1029 1030 Function _System_ASCII_ToLower(c As WCHAR) As WCHAR1031 If _System_ASCII_IsUpper(c) Then1032 Return c Or &h201033 Else1034 Return c1035 End If1036 End Function1037 1038 Function _System_ASCII_ToLower(c As SByte) As SByte1039 Return _System_ASCII_ToLower(c As Byte As WCHAR) As Byte As SByte1040 End Function1041 1042 Function _System_ASCII_ToUpper(c As WCHAR) As WCHAR1043 If _System_ASCII_IsLower(c) Then1044 Return c And (Not &h20)1045 Else1046 Return c1047 End If1048 End Function1049 1050 Function _System_ASCII_ToUpper(c As SByte) As SByte1051 Return _System_ASCII_ToUpper(c As Byte As WCHAR) As Byte As SByte1052 End Function1053 1054 970 Function _System_GetHashFromWordArray(p As *Word, n As SIZE_T) As Long 1055 971 Dim hash = 0 As DWord
Note:
See TracChangeset
for help on using the changeset viewer.