Shift operators


The following are shift operators:

·        >> right shift
·        << left shift
·        >>> right shift including negative bit

The more obscure the topic, the more likely it will appear on the exam. Operators such as +, -, *, and / will probably not be on the exam because they are commonly used. Shift operators are rarely or never used; therefore, they will most definitely be tested.

The shift operators shift the bits of a number to the right or left, producing a new number. Shift operators are used on integral numbers only (not float numbers). To determine the result of a shift, it is necessary to convert the number into bits. Let’s look at an example of a bit shift, without using code.

We’ll start with a simple example. Let’s use the right-shift operator on the integer 8. First, we must convert this number to a bit representation:

0000 0000 0000 0000 0000 0000 0000 1000

An int is a 32-bit integer, so all 32 bits must be displayed. If we apply a bit shift of one to the right, using the >> operator, the new bit number is:

0000 0000 0000 0000 0000 0000 0000 0100

We can now convert this back to a decimal number (base 10), to get 4. Now let’s examine how to do the exact same thing with code:

class BitShift {
   public static void main(String [] args) {
      int x = 8;
      System.out.println(”Before shift x equals ” + x);
      x = x >> 1;
      System.out.println(”After shift x equals ” + x);
   }
}

When we compile and run this program we get the following output:

c:\Java Projects\BitShift>java BitShift
Before shift x equals 8
After shift x equals 4

As you can see, the results are exactly what we expected them to be. Shift operations can take place on all integral numbers, regardless of the base they are displayed in (octal, decimal, or hexadecimal). The left shift works in exactly the same way, except all bits are shifted in the opposite direction. The following code uses a hexadecimal number to shift:

class BitShift {
   public static void main(String [] args) {
      int x = 0×80000000;
      System.out.println(“Before shift x equals “ + x);
      x = x << 1;
      System.out.println(“After shift x equals “ + x);
   }
}

To understand the preceding example, it is necessary to convert the hexadecimal number to a bit number. Fortunately it is very easy to convert from hexadecimal to bits. Each hex-digit converts to a four-bit representation, as we can see:

8    0    0    0    0    0    0    0
1000 0000 0000 0000 0000 0000 0000 0000

In the preceding example, the very leftmost bit represents the sign (positive or negative). When the leftmost bit is 1 the number is negative, and when it is 0 the number is positive. Running our program gives us the following:

c:\Java Projects\BitShift>java BitShift
Before shift x equals -2147483648
After shift x equals 0

As we can see, shifting the bits one to the left moves the bit right out of the number, leaving us with all 0 bits.

When there is a negative bit and we shift to the right, the operator shifts the bit to the right but also keeps the negative bit. For example, let’s use the hex number 0×80000000 again:

1000 0000 0000 0000 0000 0000 0000 0000

Now we will shift the bits, using >>, one to the right:

1100 0000 0000 0000 0000 0000 0000 0000

As we can see, the bit is shifted to the right but (and this is important) the negative bit remains behind. Let’s try some code that shifts it four to the right:

(全文…)

VeryCD将于本月关闭 P2P历史即将终结


CitNews科技资讯网 12月8日消息,继中国第一P2P门户BTChina命运终结之后,国内未取得国家广播电视总局视听许可证的各大P2P网站,都开始了紧张的转型工作。
  不止BTChina一家,在近期已经被关的BT站点被关了400逾家。黄希威表示,“其实BTChina被关是迟早的事,只是想坚持到最后一刻。同时表示对网传自己被拘留的谣言做出澄清”。
  关于VeryCD是否被封是时下网民最关心的问题,根据一名VeryCD管理员透露,VeryCD将开始全面转型到校内网,开心网这样的SNS交友网站,依托VeryCD常年积累的人气来打造“电驴乐园而电驴下载部分将在本月内关闭。
  广电总局此次大手笔关闭P2P站点,表示了要整顿非法视频分享的决心。不符合广电总局条文规定的P2P网站都要面临“生死考验”。只是大批的用户一下子失去了自己的“家园”,数千万计的P2P用户的“流离失所”一点都不亚于“魔兽”的停服风波。
  另据广电总局内部工作人员透露,12月11日即将展开下一批的非法视听站点的备案取缔工作。未取得广电总局的视听服务许可证即将被取缔的网站包括:影视帝国,VeryCD,猪猪乐园,圣城家园,飞鸟影苑,人人影视,CHD联盟,伊甸园,电影天堂,BT之家,TLF论坛,悠悠鸟,无极BT,BT 无忧无虑,BT神话等200多家非法视听服务站点。

Float primitive types


Floating-point return types are slightly more complicated than integer types. A method with a return type of a floating-point number can return integers as well as float types. In other words, a floating-point number can return integral numbers, but integrals can’t return floating-point numbers. This also applies to the char type. As discussed earlier, a char is well within the range of floating-point number types (0 to 65535). Examine the following method:

public double getValue() {
   long a = 100;
   return a;
}

The preceding method declares a return type of double. If we look within the method, however, we see it is actually returning an integer type of long. This works because a double is capable of storing numbers with or without fractions after the decimal. Table 2-3 shows the legal return types for floating-point numbers. Notice that a 32-bit float can actually return a 64-bit long.

Declared Type    Legal Return Types
float            byte, short, int, long, float, char
double            byte, short, int, long, float, double, char

Table 3: Legal Return Types for Floating-Point Numbers

It is also worth mentioning that a method with a double return type can also return a type of float. This is because a 64-bit double has enough space to hold a 32-bit float.

public double getValue() {
   float a = 8920.12518f;
   return a;
}

It is illegal for a primitive to be assigned to null. In other words, if a method declares a primitive return type, then the method may not attempt to return null.

(全文…)

Integer primitive types


A method that declares an integral return type (int, byte, short, or long) can return only an integral value, or sometimes a char value. This includes returning the result of an expression that evaluates to an integral value. Examine the following method:

public int getValue() {
   int a = 200;
   return a + 50;
}

This is a very simple method that declares the return type as an int type. If we look in the method, we can see it is returning the value of an int variable named a plus 50. This is all very normal, but we can also return other integral types. Examine the following revised code:

public int getValue() {
   byte a = 100;
   return a;
}

This method will work just fine in a class. The reason it works is because an int value is larger than a byte; therefore, int is able to store a byte value. Both a short type and a long type can also store a byte, because they too are larger than a byte. In general, an integral type can hold a place value for a smaller integral type. For example, a long can hold an int, but an int can’t hold a long.

We discussed char types earlier. A char ranges from 0 to 65535, so this means int and long are the only two integral types that can legally return a type of char. The following code demonstrates this in action:

public int getValue() {
   char a = ‘d’;
   return a; // legal
}

When a method has a declared integral type (byte, short, int, or long), it cannot return a floating-point number (float or double), even if the floating-point number has no fraction after the decimal. Examine the following code:

public int getValue() {
   float a = 100;
   return a;
}

If we insert this method into a class and attempt to compile the code, it will result in the following error:

c:\Java Projects\BookTest>javac Return.java
Return.java:4: Incompatible type for return. Explicit cast needed to
convert float to int.
   return a;
1 error

Table 2-2 shows the integer types that other integer variables can store legally.

Declared type    Legal return types
byte            byte
short            byte, short
int                byte, short, int, char   
long            byte, short, int, long, char
Table 2: Legal Return Types for Integer Numbers

A good way to determine whether an integral return type is legal is to think of the number of bits that a primitive can hold. If the bits value of the return type is less than the declared return type, it is legal.

JavaScript setDate() 方法


JavaScript setDate() Method
定义和用法
setDate()方法用于设置月份中的某一天
句法
dateObject.setDate(day)
参数

描述
必需,月份中代表某一天的值

如果day>31或者当月的天数 则顺延到下一月 如果为负数 则减 如果为0 则为前一月的最后一天编程
setDate例子
<html>
<body>

<script type=”text/javascript”>

var d = new Date();
d.setDate(15);
document.write(d);

</script>

</body>
</html>

结果为:
Tue Dec 15 2009 20:31:26 GMT+0800

如果

document.write(d.totoGMTString());

则结果为:Mon, 30 Nov 2009 12:45:33 GMT

JavaScript中toGMTString函数方法是返回一个日期,该日期用格林威治标准时间 (GMT) 表示并已被转换为字符串。使用方法:

dateObj .toGMTString()

JavaScript中toGMTString函数方法已经过时,之所以仍然提供这个方法,只是为了提供向后的兼容性。推荐改用 toUTCString 方法。
toGMTString 方法返回一个 String 对象,此对象中包含了按照 GMT 惯例进行格式化的日期。返回值的格式如下:”Mon, 30 Nov 2009 12:45:33 GMT”。

JavaScript中escape()函数用法


escape 方法返回一个包含了 charstring 内容的字符串值( Unicode 格式)。所有空格、标点、重音符号以及其他非 ASCII 字符都用 %xx 编码代替,其中 xx 等于表示该字符的十六进制数。例如,空格返回的是 “%20″ 。字符值大于 255 的以 %uxxxx 格式存储。

escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串。

语法
escape(string)

参数      描述

string    必需。要被转义或编码的字符串。

返回值

已编码的 string 的副本。其中某些字符被替换成了十六进制的转义序列。

说明

该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: – _ . ! ~ * ‘ ( ) 。其他所有的字符都会被转义序列替换。

注意   escape 方法不能够用来对统一资源标示码 (URI) 进行编码。对其编码应使用 encodeURI 和encodeURIComponent 方法。

中科院武汉病毒所生物信息学招聘


一、招聘岗位
程序员:1名
二、岗位职责
从事生物信息学软件开发和设计以及超级计算机系统维护等工作。
三、岗位要求
1. 计算机科学或计算数学相关专业硕士或以上学位,有较强的微积分、微分方程和数学
分析能力,具有Java(Swing或其他GUI包)、C 或Perl 开发经验,熟悉Linux操作系统及
集群的应用和维护。
2. 有较强的英语写作和口头表达能力,年龄35周岁以下。毕业后有1年以上相关工作经验
者优先。

(全文…)

生物信息学数据库网站


• European Molecular Biology Laboratory (EMBL) ,欧洲分子生物学实验室。
http://www.ebi.ac.uk/ebi_docs/embl_db/ebi/topembl.html
Cambridge, UK.

• UK Human Genome Mapping Project – Resource Center (HGMP-RC) ,英国医学研究委员会所属人类基因组图谱资源中心。
http://www.hgmp.mrc.ac.uk/default.htm

• SeqNet: UK Node of European Molecular Biology Network (EMBNet) ,欧洲分子生物学信息网。
http://www.seqnet.dl.ac.uk/default.htm

• GenBank ,美国国家生物技术信息中心 (NCBI)所维护的供公众自由读取的、带注释的DNA序列的总数据库。
http://www.ncbi.nlm.nih.gov/Web/Search/index.html
GenBank at the National Center for Biotechnology (NCBI) of The National Library of Medicine (NLM) at  The National Institutes for Health (NIH) campus, USA.

• National Center for Biotechnology Information (NCBI), 美国国家生物技术信息中心
http://www.ncbi.nlm.nih.gov/

• DNA Databank of Japan (DDBJ) ,日本核酸数据库。
http://www.ddbj.nig.ac.jp/default.htm

• Genome Sequence DataBase (GSD ,美国国家基因组资源中心维护的DNA序列关系数据库。
http://seqsim.ncgr.org/default.htm
The National Center for Genome Resources, Genome Sequence Database.
The server is a supercomputer with genomic algorithm accelleration.

• Online Mendelian Inheritance in Man (OMIM), 在线人类孟德尔遗传数据库 。
http://www3.ncbi.nlm.nih.gov/Omim/searchomim.html
Database of human genes and their disorders, with textual information, images and references. Links to Entrez and MedLine. (全文…)

Python和Perl比较


1:Perl太灵活
2:Perl程序,很难看懂
3:Python面向对象编程
4:Python的图形界面编程很简洁
5:Python的使用率已经高过Perl了,这是个趋势;
6:Google等大公司都在使用Python

Method and variable access control


Access control can be a difficult concept to learn because there are many factors and combinations of factors that can make a difference in which members can be accessed. These concepts are essential to know for the certification exam.

Methods and variables are collectively known as members. Because method and variable members are given access control in exactly the same way, I will explain them in the same section.

There are four types of member access control:

· public

· private

· protected

· default

Default protection is achieved by using no access modifier in the member declaration. The default and protected access control types have almost identical behavior, except for one difference, which will be mentioned later.

 

It is very important to know access control inside and out for the exam. There are at least five questions that will deal specifically with this topic. Each question will test several concepts of access control at the same time, so not knowing one small part of access control could blow an entire question.

What does it mean for a class to have access to members of another class? For now, ignore any differences between methods and variables. If a class has access to another member, it means it is visible to it. When a class has no access to another member, the compiler will behave as though the member you are attempting to reference does not exist (even though it is only hidden).

There are two types of access that we must look at. The first type of access is when a method tries to access a method or a variable of a class or object. The second type of access that we are concerned with is when a class extends another class. In this case, the subclass can access certain members of the superclass, depending on what the access is on those members.

Keep in mind that different modifiers can control access to a class member based on whether the class belongs to the same package or a different package. It is also important to note that, as mentioned earlier, if the class itself can’t be accessed then no members within it can be accessed either. We will now discuss public, private, protected and default access in depth.

 

Often, new students of Java wonder what the effects are of different combinations of class and member access (such as a default class with a public variable). To figure this out, first look at the access level of the class. If the class itself will not be visible to another class, then none of the members will be either, even if the member is declared public. Once it is confirmed that the class is visible, then it is prudent to look at access levels on individual members.

Public members

When a method or a variable member is declared public, it means all other classes, regardless of the package that they belong to, can access the member (assuming the class itself is visible). Examine the following source file:

(全文…)

Page 3 of 22«12345678910»20...Last »

绿程网坚持自由、开放、共享的原则

围绕web开发生物分析提供免费的在线编程教程生物教程等资源。