Code
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head >
< Title > New Document </ Title >
< Meta Name = "Generator" Content = "Editplus" />
< Meta Name = "Author" Content = "" />
< Meta Name = "Keywords" Content = "" />
< Meta Name = "Description" Content = "" />
</ Head >
< Body >
< Script Type = "Text/JavaScript" Language = "JavaScript" >
/*
Number of consumers
*/
Function Getmaxnum ()
{
If ( Arguments. Length <= 1 )
{
Return Arguments [ 0 ];
}
VaR ARG = Arguments;
VaR Max = Arg [ 0 ];
VaR I = 1 ;
While (I < Arg. length)
{
// A number is represented by 32 bits, and the highest bits is the symbol (0 is positive and 1 is negative). Therefore, the two bits are subtracted, and the result is shifted to 31 bits, retaining the symbol bit.
// It is followed by the sign bit and Phase 1, and 0 is positive and 1 is negative.
Max = (Max - Arg [I]) > 31 ) & 1 ) = 0 ? MAX: Arg [I];
++ I;
}
Return Max;
}
Function Get1num (Num)
{
VaR Count = 0 ;
While (Num > 0 )
{
// The binary value of A number indicates the number of 1.AlgorithmIs: this number minus 1, and then with its own phase, this cycle until the number is less than or equal to 0. The number of cycles is 1.
Num = (Num - 1 ) & Num;
Count ++ ;
}
Return Count;
}
Document. Write ( " The large numbers in 10,-17.23, and 12 are: " + Getmaxnum ( 10 , - 2 , 15 , 17.23 , 13 , 12 ));
Document. Write ( " <Br/> in the binary representation of 7, the number of 1 is: " + Get1num ( 7 ));
</ Script >
</ Body >
</ Html >