|
of_binary
|
|
Full name
|
pfc_n_cst_numerical.of_binary
|
Access
|
public
|
Extend of
|
string
|
Return value
|
string
|
Prototype
|
public function string of_binary(long)
|
Name
|
Datatype
|
li_remainder
|
integer
|
ls_binary
|
string
|
ls_null
|
string
|
public function string of_binary (long al_decimal);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_Binary
//
// Access: public
//
// Arguments:
// al_decimal Decimal value whose binary representation needs to be determined (e.g. 57)
//
// Returns: string
// The binary representation of the decimal number. (e.g. 10101)
// If any argument's value is NULL, function returns NULL.
// If any argument's value is Invalid, function returns NULL.
//
// Description: Determines the Binary representation of a Decimal number.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
integer li_remainder
string ls_binary=''
//Check parameters
If IsNull(al_decimal) or al_decimal< 0 Then
string ls_null
SetNull(ls_null)
Return ls_null
End If
If al_decimal = 0 Then
Return '0'
End If
Do Until al_decimal= 0
li_remainder = mod(al_decimal, 2)
al_decimal = al_decimal /2
//Build binary string
ls_binary = string(li_remainder) + ls_binary
Loop
Return ls_binary
end function
Name
|
Owner
|
systemfunctions.isnull |
systemfunctions
|
systemfunctions.mod |
systemfunctions
|
systemfunctions.setnull |
systemfunctions
|
systemfunctions.string |
systemfunctions
|