??xml version="1.0" encoding="utf-8" standalone="yes"?>日本中文字幕在线一区,九九热爱视频精品视频,欧洲精品久久久久毛片完整版http://www.aygfsteel.com/orangehf/archive/2012/12/18/393139.htmlTue, 18 Dec 2012 04:56:00 GMThttp://www.aygfsteel.com/orangehf/archive/2012/12/18/393139.htmlhttp://www.aygfsteel.com/orangehf/comments/393139.htmlhttp://www.aygfsteel.com/orangehf/archive/2012/12/18/393139.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/393139.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/393139.html
Repost from http://east82.com/howto/ip_addressing/bin_dec_hex.htm 

BIND DNS UbuntuUnderstanding Binary, Decimal and Hexadecimal - A Tutorial

"There are 10 kinds of people in the world ...those who understand binary and those who do not"

A primer in numbering systems

There are four basic numbering systems that are used in the human, networking, and computer science worlds. Binary, octal, decimal and hexadecimal. Decimal, the numbering system we are most familiar with has a base, or radix, of 10 and to us this is natural. Why 10? Most of us have 10 fingers and that is how it was selected as our numbering system; it's as simple as that. The Yuki people of California on the other hand (pun intended) use an octal numbering system, counting the spaces between their fingers and not the fingers themselves. Pretty cool, huh?

The other systems widely in use in the networking and computer science world are binary, octal and hexadecimal (See table below). In this tutorial we'll concern ourselves only with binary, decimal and hexadecimal, ignoring octal altogether. As a side note, one use of octal numbering is with Linux and UNIX systems to set file permissions using the chmod command.
Binary Octal Decimal Hexadecimal numbering systems

It's all just ones and zeros - bits and nibbles and bytes oh my!

Yes, we're talking binary here. I start here by asking that you don't think of a binary number as being a just series of 1's and 0's, such as 01000001 (65 decimal), but rather as a valid numbering system. So, why binary and not decimal? Take our previous example of 01000001. It's really a sort of computer Morse code, but instead of dots and dashes, it's the presence or absence of state, on or off; whether it be electrical pulses on an Cat5 cable or the state of transistors within a CPU or memory stick. Individually a bit, that is a 1 or 0, is pretty useless. However, put them together in a byte (8 bits) for example, then you have something. With our previous example, the byte 01000001 represents the character 'A'. With the computer's ability to process and transmit millions of bytes in miliseconds it can give us letters, words, pictures, music, videos and oodles of other things almost instantly. No matter what we type or create via keyboard or mouse, eventually it all gets translated into a numerical series of 1's and 0's to represent our intent. So, you see it IS all just 1's and 0's! Oh, I almost forgot ...a nibble is half a byte, 4 bits.

Thinking in binary

With the decimal numbering system we have 10 digits to work with, 0 thru 9 and when we count we start at 0, then 1, then 2 and so on until we reach 9. Then what? Well, we've run out of digits. So, we start again at 0, but we place a 1 to the left giving us 10 (ten). And once the 1's and 10's columns reach 9 and 9 (99) they  both flip, giving us 100. Same thing goes with binary except we only have 2 digits to work with, 1 and 0.

The principal is the same we start at 0 then 1, then ...well, we've run out of digits haven't we? So, we flip that 1 to 0 and place a 1 to the left giving us 10 (two). Increment by 1 again and we have 11 (three) and once again they both flip and we move into a new column giving us 100 (four). This is probably not so bad for small numbers, but once you get past 8 or so binary digits it becomes unmanageable. I mean what does 10011100 equate to in human terms? Don't even mention that binary numbers are unwieldy; 3,000 is 101110111000 in binary ...geez! So, while it is true that we need to think in binary, we can represent these binary numbers in a more human friendly form. Anyone say decimal? Fortunately we have the ability (and absolute need) to convert between the two. 

Converting binary to decimal

For this section I'll start by examining and explaining the table below.
Binary byte decimal table

  • First thing  to take note of is that there are 8 individual bits giving us a byte. When working with IP addresses, networking folks refer to this as an octet. Obviously, binary numbers can be larger than a simple byte. However, the byte is the most basic representation of data and as such, for the most part, we'll stay at the byte level.

  • The 'Bit Set' row is for our binary digits, either 0 or 1. Here they are all 1.

  • The 'Exponent Value' row is how we arrive mathematically at the 'Decimal Value' row. An exponential value such as 23 means 2 x 2 x 2 = 8. By the way, any number with an exponent of 0 ALWAYS equates to 1 (2= 1 and 4000 also = 1).    

  • The 'Decimal Value' row represents positionally the decimal value of the binary digit in question. It's imperative that you commit this row to memory. Practice by writing it down over and over 'till its part of your DNA :-)

128           64           32            16           8           4           2           1
  • The labels 'MSB' and 'LSB' stand for 'Most Significant Bit' and 'Least Significant Bit' respectively. This lets us know which end of the binary number we are talking about. For example, if I had a binary number of 11010101 and I say 'Starting at bit 1' ...that might be confusing. However, if I say 'Starting with the bit at LSB 1'. Well, you get the picture.

Previously we talked about thinking in binary means knowing how to count in binary and that still holds valid, but now, in order to convert between the two, we are going to only concern ourselves with the position of each binary digit as it relates to its decimal equivalent. What?? OK, take for example the binary number 00001010. Referring to the table above just add the positional decimal equivalents where the 1's occur. So, 00001010 means 128 (no), 64 (no), 32 (no), 16 (no), 8 (yes), 4 (no), 2 (yes) 1 (no). Given that, we see that 8 + 2 =10. In other words 00001010 binary is 10 decimal. Here are a few more examples.

  • 11000000 - 128 + 64 = 192

  • 00000001 - = 1

  • 00110011 - 32 + 16 + 2 + 1 = 51

  • 11011011 - 128 + 64 + 16 + 8 + 2 + 1 = 219

  • 00000000 - = 0

  • 11111111 - 128 + 64 + 32 +16 + 8 + 4 + 2 + 1 = 255

If you encounter a binary number less than a byte such as 11001 (25 decimal), just pad the missing binary digits with 0's, making the number 00011001, a complete byte. Also, if you are presented with a binary number larger than a byte then double the decimal number with each subsequent binary position to the left. See table below. Later, when we work with subnetting, we'll use these larger values. Expanded binary to decimal table

At this point you should be comfortable with converting binary to decimal. Now let's go the other way, decimal to binary. I'll show you two different methods. Use the one that best works for you.

Method 1 - Process of Elimination

This method is pretty straight forward. The first thing to do is write down the decimal value row previously covered.

128           64           32            16           8           4           2           1

Next, somewhere off to the side, write down your decimal number. With a byte, or octet, the smallest number is 0 and the largest 255, so your number must be within this range. Next, follow the procedure below:

Compare the decimal number with the MSB (128). If your number is larger than or equal to 128 then place a 1 under the 128 column, subtract 128 from your number and move to the next position (64). However, if your number is less than 128 then place a 0 under the 128 column and move to the next number (64) without subtracting.

Repeat the above process with 64, 32, 16 etc. until your original number is reduced to zero. If you reach zero before reaching the LSB (1) fill in the remaining columns with 0's. below are a few examples:
Decimal to binary conversion examples

Method 2 - Divide and Conquer

This method has you repeatedly dividing a decimal number by 2 and saving the remainder, either 1 or 0, as a binary digit. Keep doing this until, again, your original number has been reduced to 0. It's not as confusing as it sounds. Let's walk through an example:
Decimal to binary conversion division exampleRefer to the example above. Given the decimal number 41 and the divide-and-conquer method, we derive its binary equivalent with the following logic:

  • 41 divided by 2 is 20, remainder 1. Place a 1 in the remainder column and 20 in the division column. This is the LSB and will be the rightmost binary digit.

  • 20 divided by 2 is 10, remainder 0. Place a 0 in the remainder column and 10 in the division column.

  • 10 divided by 2 is 5, remainder 0. Place a 0 in the remainder column and 5 in the division column.

  • 5 divided by 2 is 2, remainder 1. Place a 1 in the remainder column and 2 in the division column.

  • 2 divided by 2 is 1, remainder 0. Place a 0 in the remainder column and 1 in the division column.

  • 1 divided by 2 is 0, remainder 1. Place a 1 in the remainder column and we're done ...

... well almost. Our solution came out to be only 6 binary digits long. Since we are working with bytes, just pad the left with 0's until the binary number is 8 digits in length. One more thing. Your last operation will always be 1/2 = 0, remainder 1. Here a couple more examples:
Decimal to binary conversion
 

Binary and decimal numbers larger than a byte

At times you might have a binary or decimal that is larger than a byte. Don't panic. All you need to do is extend the binary byte row to the left, doubling as you go along.

128           64           32            16           8           4           2           1

now becomes the following if we have a 12 bit binary number:

2048     1024     512     256     128     64     32     16     8     4    2     1

Here is a sample conversion from binary to decimal using process of elimination:
Large decimal number to binary conversion

Moving on to hexadecimal

Just when you got your head around binary and decimal, along comes hexadecimal, hex for short. Before, I mentioned that everything in the computing and networking arena is nothing more that 1's and 0's and that axiom remains unchanged. We now know how to convert back and forth between binary (what the computer speaks) and decimal (what we speak), so why do we even need hex? Besides being an efficient numbering system, hexadecimal is widely used to represent to us humans the 1's and 0's that traverse circuits and wires. A few examples where hex numbers are used are colors, memory references, IPv6 addresses and MAC addresses. Let's explore this a little more in detail.

A binary byte is exactly eight digits long, e.g. 00101110 and a hex byte number is exactly two digits in length, e.g. 6A. A decimal byte on the other hand is anywhere between one and three digits long, e.g. 4, 64 or 233. Yes, you could pad these with 0's making 004, 064 and 233, but this is still not as efficient or as practical as hex. (as we'll see when we start converting hex and binary numbers). Download myextended ASCII table; it will help with the following illustration and serve as a useful refernece for your studies:
Memory dump
 This screenshot is a memory dump of my computer. Imagine if those numbers were represented in binary!

Let's get on with it.

What the hex are you talking about?

Below is a hex table with decimal equivalents:
Hexadecimal decimal table

With hex, the first 10 digits, 0 thru 9, are the same as decimal. However, 10 thru 15 decimal are represented as a single hex digit A thru F. The number 5 in decimal is 5 in hex and the number 13 in decimal is D in hex. What happens when we reach F (15 decimal) and need to increment by 1 is that, just like with all other numbering systems, we flip that to 0 and place a one to the left. 0xF + 0x1 = 0x10. What is this 0x business? Placing 0x in front of a hex number is the typical way to indicate it's really hex. It makes it clear that 11 (decimal) and 0x11 (hex) are two different numbers entirely. So, from here on out I'll use the 0x to indicate hexadecimal numbers. Sometimes you'll see the hex numbers 0xA thru 0xF written in lower case (0xa thru 0xf). There's nothing wrong with that and it does not change the numerical value of the number in question. I use caps in this how-to.

Binary to hex - nibbles and bits

To convert a binary byte to hex byte, first split the binary number into two nibbles, treating them as separate numbers, and then compute the hex equivalent for each half. Finally, concatenate the two hex numbers into a single solution. This works perfectly because a nibble has a value from 0 thru 15 or 0x0 thru 0xF.
Binary hex range

Here's some examples:
Binary to hex conversion examples

Binary to hex - bits and nibbles

The conversion process from hex to binary is not much different, we just reverse the process. A picture is worth a thousand words. Here's 4,000 of them.
Hexadecimal to binary conversion examples

Once in a while you may find yourself presented with a binary or hex number larger than a byte. The methods are the same, just expanded. If you have a binary number to convert then you may have to pad the MSB with 0's in order to have a binary number that falls on nibble boundaries, multiples of 4. For example, the binary number 1001100101 won't convert correctly, because it's ten digits in length. Add two 0's making the number 001001100101. A few illustrations:Large binary and hex conversions

Decimal to hex - tens to sixteens

Up to now we've been able to accomplish our conversions armed with only paper and pencil. It's time to break out your calculator for converting decimal to hex and vice versa. Take  Look at these decimal / hex equivalents:
16 = 0x10  |  34 = 0x22  |  214 = 0xD6  |  175 = 0xAF
Here's how we get from the decimal value on the left of the = sign to its hexadecimal equivalent on the right. Remember the divide and conquer method we used for converting decimal to binary? We are going to use the same method except that we are going to be dividing by 16 rather than 2. The upside is that the process is a lot shorter.
decimal to hex conversion example

  • 225 divided by 16 is 14, remainder 0x1. Place a 0x1 in the remainder column and 14 in the division column. This is our rightmost hex digit.

  • 14 divided by 16 is 0, remainder 14. Since we are converting to hex we use 0xE. Place 0xE in the remainder column and we're done.

  • If you have a small decimal number such as 12, you'll have your answer on the first divide. 12 / 16 = 0, remainder 12 or 0xC. Place a leading 0 in from of the C to keep things uniform. So, the answer would be 0x0C

How easy is that? Here are a few more:
Decimal to hexadecimal convert examples

It's no different with numbers larger than a byte:
Decimal to hexadecimal conversion

Hex to decimal - sixteens to tens

Whew! Nearly done. This is our last number conversion segment, hexadecimal to decimal. With a hex number each position represents a power of 16 and what we do is calculate each position's decimal equivalent and then add them all up. We are going to use a large hex number to illustrate this concept. Given the hex number 0xA59C we find its decimal equivalent with the following logic.
(10 x 163) + (5 x 162) + (9 x 161) + (12 x 160) = 43,296. Here's how it breaks down:
Hexidecimal to decimal conversion example

...And a few more:
Hexadecimal to decimal conversion examples

I encourage you to practice, practice, practice. Download this worksheet to work thru various conversion exercises.

Parting shot - If you are an aspiring network or systems admin then make sure you understand without question binary and decimal conversion through and through.

Coming soon - Part II Understanding IP addresses, subnet masks and subnetting.

./Robert



2012-12-18 12:56 发表评论
]]>
shell之?gt;/dev/null 2>&1?/title><link>http://www.aygfsteel.com/orangehf/archive/2011/12/01/365262.html</link><dc:creator>南</dc:creator><author>南</author><pubDate>Thu, 01 Dec 2011 01:54:00 GMT</pubDate><guid>http://www.aygfsteel.com/orangehf/archive/2011/12/01/365262.html</guid><wfw:comment>http://www.aygfsteel.com/orangehf/comments/365262.html</wfw:comment><comments>http://www.aygfsteel.com/orangehf/archive/2011/12/01/365262.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/orangehf/comments/commentRss/365262.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/orangehf/services/trackbacks/365262.html</trackback:ping><description><![CDATA[<div><font size="2" face="Tahoma">shell中可能经常能看到Q?gt;/dev/null 2>&1</font></div> <div><font size="2" face="Tahoma">命o的结果可以通过%>的Ş式来定义输出</font></div> <div><font size="2" face="Tahoma">分解q个l合Q?#8220;>/dev/null 2>&1” Z部分?/font></div> <div><font color="#ff6600" size="2" face="Tahoma">1Q?gt; 代表重定向到哪里Q例如:echo "123" > /home/123.txt<br />2Q?dev/null 代表I备文?br />3Q?> 表示stderr标准错误<br />4Q?amp; 表示{同于的意思,2>&1Q表C?的输出重定向{同?<br />5Q? 表示stdout标准输出Q系l默认值是1Q所?>/dev/null"{同?"1>/dev/null"</font></div> <div><font size="2" face="Tahoma">因此Q?gt;/dev/null 2>&1也可以写?#8220;1> /dev/null 2> &1”</font></div> <div><font size="2" face="Tahoma">那么本文标题的语句执行过EؓQ?br />1>/dev/null Q首先表C标准输出重定向到空讑֤文gQ也是不输ZQ何信息到l端Q说白了是不显CZQ何信息?br />2>&1 Q接着Q标准错误输出重定向 ?标准输出Q因Z前标准输出已l重定向CI备文Ӟ所以标准错误输Z重定向到I备文件?/font></div> <div><font size="2" face="Tahoma">说清楚了吗,大家理解下吧Q?/font></div> <div><font color="#ff6600" size="2" face="Tahoma">ZҎq说下这么用的好处!</font></div> <div><font size="2" face="Tahoma">   最常用的方式有Q?/font></div> <div><font color="#ff0000" size="2" face="Tahoma">command > file 2>file  与command > file 2>&1</font></div> <div><font size="2" face="Tahoma">它们 有什么不同的地方吗?</font></div> <div><br /><font size="2" face="Tahoma">      首先command > file 2>file 的意思是命令所产生的标准输Z?和错误的输出信息送到file ?command  > file 2>file q样的写?stdout和stderr都直接送到file? file会被打开两次,q样stdout和stderr会互相覆?q样写相当用了FD1和FD2两个同时L占file 的管道?br />      而command >file 2>&1 q条命o将stdout直接送向file, stderr l承了FD1道?再被送往file,此时,file 只被打开了一?也只使用了一个管道FD1,它包括了stdout和stderr的内宏V?br />      从IO效率?前一条命令的效率要比后面一条的命o效率要低,所以在~写shell脚本的时?较多的时候我们会command > file 2>&1 q样的写法?/font></div><br /><br />转自Q?a >http://ppp1013.blog.51cto.com/927700/271043</a><img src ="http://www.aygfsteel.com/orangehf/aggbug/365262.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/orangehf/" target="_blank">南</a> 2011-12-01 09:54 <a href="http://www.aygfsteel.com/orangehf/archive/2011/12/01/365262.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>iostat来对linux盘IO性能q行了解http://www.aygfsteel.com/orangehf/archive/2011/11/02/362534.htmlWed, 02 Nov 2011 07:14:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/11/02/362534.htmlhttp://www.aygfsteel.com/orangehf/comments/362534.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/11/02/362534.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/362534.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/362534.html转自: http://www.php-oa.com/2009/02/03/iostat.html

 以前一直不太会用这个参数。现在认真研I了一下iostatQ因为刚好有台重要的服务器压力高,所以放上来分析一?下面q台是IO有压力过大的服务?/p>

 

$iostat -x 1
Linux 2.6.33-fukai (fukai-laptop)          _i686_    (2 CPU)
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.47    0.50    8.96   48.26    0.00   36.82
  
Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               6.00   273.00   99.00    7.00  2240.00  2240.00    42.26     1.12   10.57   7.96  84.40
sdb               0.00     4.00    0.00  350.00     0.00  2068.00     5.91     0.55    1.58   0.54  18.80

rrqm/s:   每秒q行 merge 的读操作数目Q当pȝ调用需要读取数据的时候,VFS请求发到各个FSQ如果FS发现不同的读取请求读取的是相同Block的数据,FS会将q个h合ƈMergeQ。即 delta(rmerge)/s
wrqm/s:  每秒q行 merge 的写操作数目。即 delta(wmerge)/s
r/s:           每秒完成的读 I/O 讑֤ơ数。即 delta(rio)/s
w/s:         每秒完成的写 I/O 讑֤ơ数。即 delta(wio)/s
rsec/s:    每秒L区数。即 delta(rsect)/s
wsec/s:  每秒写扇区数。即 delta(wsect)/s
rkB/s:      每秒读K字节数。是 rsect/s 的一半,因ؓ每扇区大ؓ512字节?需要计?
wkB/s:    每秒写K字节数。是 wsect/s 的一半?需要计?
avgrq-sz: q_每次讑֤I/O操作的数据大?(扇区)。delta(rsect+wsect)/delta(rio+wio)
avgqu-sz: q_I/O队列长度。即 delta(aveq)/s/1000 (因ؓaveq的单位ؓ毫秒)?br />await:    q_每次讑֤I/O操作的等待时?(毫秒)。即 delta(ruse+wuse)/delta(rio+wio)
svctm:   q_每次讑֤I/O操作的服务时?(毫秒)。即 delta(use)/delta(rio+wio)
%util:      一U中有百分之多少的时间用?I/O 操作Q或者说一U中有多时?I/O 队列是非I的。即 delta(use)/s/1000 (因ؓuse的单位ؓ毫秒)

如果 %util 接近 100%Q说明生的I/Oh太多QI/Opȝ已经满负P该磁?br />可能存在瓉?br />idle于70% IO压力p大了,一般读取速度有较多的wait.
同时可以l合vmstat 查看查看b参数({待资源的进E数)和wa参数(IO{待所占用的CPU旉的百分比,高过30%时IO压力?/font>)
另外 await 的参C要多?svctm 来参考。差的过高就一定有 IO 的问题?br />avgqu-sz 也是个做 IO 调优旉要注意的地方Q这个就是直接每ơ操作的数据的大,如果ơ数多,但数据拿的小的话Q其?IO 也会很小.如果数据拿的大,才IO 的数据会高。也可以通过 avgqu-sz × ( r/s or w/s ) = rsec/s or wsec/s.也就是讲Q读定速度是这个来军_的?/strong>

 

 

 

另外q可以参?/strong>
svctm 一般要于 await (因ؓ同时{待的请求的{待旉被重复计了)Qsvctm 的大一般和盘性能有关QCPU/内存的负荷也会对其有影响Q请求过多也会间接导?svctm 的增加。await 的大一般取决于服务旉(svctm) 以及 I/O 队列的长度和 I/O h的发出模式。如?svctm 比较接近 awaitQ说?I/O 几乎没有{待旉Q如?await q大?svctmQ说?I/O 队列太长Q应用得到的响应旉变慢Q如果响应时间超q了用户可以容许的范_q时可以考虑更换更快的磁盘,调整内核 elevator 法Q优化应用,或者升U?CPU?br />队列长度(avgqu-sz)也可作ؓ衡量pȝ I/O 负荷的指标,但由?avgqu-sz 是按照单位时间的q_|所以不能反映瞬间的 I/O z水?/p>


  别h一个不错的例子.(I/O pȝ vs. 市排队)

举一个例子,我们在超市排?checkout Ӟ怎么军_该去哪个交款台呢? 首当是看排的队h敎ͼ5个hL20快吧? 除了Ch_我们也常常看看前面h购买的东西多,如果前面有个采购了一星期食品的大妈,那么可以考虑换个队排了。还有就是收银员的速度了,如果C了连 钱都点不清楚的新手,那就有的{了。另外,时机也很重要Q可?5 分钟前还人满为患的收Ƒ֏Q现在已是hLI,q时候交Ƒ֏是很爽啊Q当Ӟ前提是那q去?5 分钟里所做的事情比排队要有意?(不过我还没发C么事情比排队q无聊的)?/p>

I/O pȝ也和市排队有很多类g?

r/s+w/s cM于交ƾh的L
q_队列长度(avgqu-sz)cM于单位时间里q_排队人的个数
q_服务旉(svctm)cM于收银员的收N度
q_{待旉(await)cM于^均每人的{待旉
q_I/O数据(avgrq-sz)cM于^均每人所买的东西多少
I/O 操作?(%util)cM于收Ƒ֏前有人排队的旉比例?/p>

我们可以Ҏq些数据分析?I/O h的模式,以及 I/O 的速度和响应时间?/p>

下面是别人写的这个参数输出的分析

# iostat -x 1
avg-cpu: %user %nice %sys %idle
16.24 0.00 4.31 79.44
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
/dev/cciss/c0d0
0.00 44.90 1.02 27.55 8.16 579.59 4.08 289.80 20.57 22.35 78.21 5.00 14.29

上面?iostat 输出表明U有 28.57 ơ设?I/O 操作: 总IO(io)/s = r/s(? +w/s(? = 1.02+27.55 = 28.57 (?U? 其中写操作占了主?(w:r = 27:1)?/p>

q_每次讑֤ I/O 操作只需?5ms 可以完成,但每?I/O h却需要等?78msQؓ什? 因ؓ发出?I/O h太多 (每秒钟约 29 ?Q假设这些请求是同时发出的,那么q_{待旉可以q样计算:

q_{待旉 = 单个 I/O 服务旉 * ( 1 + 2 + … + hL-1) / hL

应用C面的例子: q_{待旉 = 5ms * (1+2+…+28)/29 = 70msQ和 iostat l出?8ms 的^均等待时间很接近。这反过来表?I/O 是同时发L?/p>

每秒发出?I/O h很多 (U?29 ?Q^均队列却不长 (只有 2 ?左右)Q这表明q?29 个请求的到来q不均匀Q大部分旉 I/O 是空闲的?/p>

一U中?14.29% 的时?I/O 队列中是有请求的Q也是_85.71% 的时间里 I/O pȝ无事可做Q所?29 ?I/O h都在142毫秒之内处理掉了?/p>

delta(ruse+wuse)/delta(io) = await = 78.21 => delta(ruse+wuse)/s =78.21 * delta(io)/s = 78.21*28.57 = 2232.8Q表明每U内的I/Ohd需要等?232.8ms。所以^均队列长度应?2232.8ms/1000ms = 2.23Q?iostat l出的^均队列长?(avgqu-sz) 却ؓ 22.35Qؓ什?! 因ؓ iostat 中有 bugQavgqu-sz 值应?2.23Q而不?22.35?/p>

2011-11-02 15:14 发表评论
]]>
Understanding software Installation (configure, make, make install)http://www.aygfsteel.com/orangehf/archive/2011/09/28/359689.htmlWed, 28 Sep 2011 06:01:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/09/28/359689.htmlhttp://www.aygfsteel.com/orangehf/comments/359689.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/09/28/359689.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/359689.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/359689.htmlThis tutorial is aimed at those who have just started using Linux. Generally when users from the Windows background enter the Linux scene,they are totally stumped by the software installation method. They were used to the luxury of double clicking on a single file and getting their software installed. But now they have to type cryptic commands to do the same.

Though the installation instructions tell them what to do, they have no idea what those steps actually do. This article shall explain the basics of software installation. After reading this article you would feel more at home when installing your next software.

Generally beginners tend to search desperately for RPMs since installing RPMs is a real simple task. But this article doesn't talk about RPMs. It deals with the softwares that you generally get in the zipped formats as tarballs.


Details :

Generally you would get Linux software in the tarball format (.tgz) This file has to be uncompressed into any directory using tar command. In case you download a new tarball by the name game.tgz, then you would have to type the following command

$ tar xfvz game.tgz

This would create a directory within the current directory and unzip all the files within that new directory. Once this is complete the installation instructions ask you to execute the 3 (now famous) commands : configure, make & make install. Most of the users do this and successfully install their softwares. But most of the newbies have no idea what this really does. The rest of the article shall explain the meaning of these 3 commands

Each software comes with a few files which are solely for the purpose of installation sake. One of them is the configure script. The user has to run the following command at the prompt

$ ./configure

The above command makes the shell run the script named ' configure ' which exists in the current directory. The configure script basically consists of many lines which are used to check some details about the machine on which the software is going to be installed. This script checks for lots of dependencies on your system. For the particular software to work properly, it may be requiring a lot of things to be existing on your machine already. When you run the configure script you would see a lot of output on the screen , each being some sort of question and a respective yes/no as the reply. If any of the major requirements are missing on your system, the configure script would exit and you cannot proceed with the installation, until you get those required things.

The main job of the configure script is to create a ' Makefile ' . This is a very important file for the installation process. Depending on the results of the tests (checks) that the configure script performed it would write down the various steps that need to be taken (while compiling the software) in the file named Makefile.

If you get no errors and the configure script runs successfully (if there is any error the last few lines of the output would glaringly be stating the error) then you can proceed with the next command which is

$ make

' make ' is actually a utility which exists on almost all Unix systems. For make utility to work it requires a file named Makefile in the same directory in which you run make. As we have seen the configure script's main job was to create a file named Makefile to be used with make utility. (Sometimes the Makefile is named as makefile also)

make would use the directions present in the Makefile and proceed with the installation. The Makefile indicates the sequence, that Linux must follow to build various components / sub-programs of your software. The sequence depends on the way the software is designed as well as many other factors.

The Makefile actually has a lot of labels (sort of names for different sections). Hence depending on what needs to be done the control would be passed to the different sections within the Makefile Or it is possible that at the end of one of the section there is a command to go to some next section.

Basically the make utility compiles all your program code and creates the executables. For particular section of the program to complete might require some other part of the code already ready, this is what the Makefile does. It sets the sequence for the events so that your program does not complain about missing dependencies.

One of the labels present in the Makefile happens to be named ' install ' .

If make ran successfully then you are almost done with the installation. Only the last step remains which is

$ make install

As indicated before make uses the file named Makefile in the same directory. When you run make without any parameters, the instruction in the Makefile begin executing from the start and as per the rules defined within the Makefile (particular sections of the code may execute after one another..thats why labels are used..to jump from one section to another). But when you run make with install as the parameter, the make utility searches for a label named install within the Makefile, and executes only that section of the Makefile.

The install section happens to be only a part where the executables and other required files created during the last step (i.e. make) are copied into the required final directories on your machine. E.g. the executable that the user runs may be copied to the /usr/local/bin so that all users are able to run the software. Similarly all the other files are also copied to the standard directories in Linux. Remember that when you ran make, all the executables were created in the temporary directory where you had unzipped your original tarball. So when you run make install, these executables are copied to the final directories.

Thats it !! Now the installation process must be clear to you. You surely will feel more at home when you begin your next software installation.
原文地址Q?a >http://www.codecoffee.com/tipsforlinux/articles/27.html

2011-09-28 14:01 发表评论
]]>
oracle rmanhttp://www.aygfsteel.com/orangehf/archive/2011/09/15/358724.htmlThu, 15 Sep 2011 08:54:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/09/15/358724.htmlhttp://www.aygfsteel.com/orangehf/comments/358724.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/09/15/358724.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/358724.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/358724.htmlhttp://www.bccn.net/Article/sjk/oracle/200601/3470_2.html
http://www.beifenruanjian.com/oracle/redhat-linux-as4-on-the-use-of-rman-for-backup-and-recovery-testing/
http://blog.sina.com.cn/s/blog_3fb41b900100h7sg.html
http://database.e800.com.cn/articles/2008/116/1200428070211771370_1.html
http://blog.csdn.net/tianlesoftware/article/details/4699320

rman 恢复Q?br />http://space.itpub.net/9765498/viewspace-237930
http://space.itpub.net/8334342/viewspace-521139

2011-09-15 16:54 发表评论
]]>
Oracle 表解?http://www.aygfsteel.com/orangehf/archive/2011/08/22/357052.htmlMon, 22 Aug 2011 08:04:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/08/22/357052.htmlhttp://www.aygfsteel.com/orangehf/comments/357052.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/08/22/357052.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/357052.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/357052.htmlSELECT /*+ rule */
 s.username,
 decode(l.type, 
'TM''TABLE LOCK''TX''ROW LOCK'NULL) LOCK_LEVEL,
 o.owner,
 o.
object_name,
 o.object_type,
 s.sid,
 s.serial#,
 s.terminal,
 s.machine,
 s.program,
 s.osuser
  
FROM v$session s, v$lock l, dba_objects o
 
WHERE l.sid = s.sid
   
AND l.id1 = o.object_id(+)
   
AND s.username is NOT Null

2.q行解锁
1alter system kill session 'sid,serial#';


2011-08-22 16:04 发表评论
]]>
ORACLE扚wl定FORALL与BULK COLLECT http://www.aygfsteel.com/orangehf/archive/2011/08/22/357028.htmlMon, 22 Aug 2011 04:55:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/08/22/357028.htmlhttp://www.aygfsteel.com/orangehf/comments/357028.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/08/22/357028.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/357028.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/357028.htmlhttp://log-cd.iteye.com/blog/411122

FORALL与BULK COLLECT的用方?
1Q用FORALL比FOR效率高,因ؓ前者只切换一ơ上下文Q而后者将是在循环ơ数一样多个上下文间切换?

2Q用BLUK COLLECT一ơ取Z个数据集合,比用游标条取数据效率高,其是在|络不大好的情况下。但BLUK COLLECT需要大量内存?

例子:
1create table test_forall ( user_id number(10), user_name varchar2(20));

select into 中用bulk collect
 1DECLARE  
 2  TYPE table_forall IS TABLE OF test_forall%ROWTYPE;   
 3  v_table table_forall;   
 4BEGIN  
 5    SELECT mub.user_id,mub.user_name   
 6         BULK COLLECT INTO v_table   
 7    FROM mag_user_basic mub   
 8         WHERE mub.user_id BETWEEN 10000 AND 10100;   
 9    FORALL idx IN 1..v_table.COUNT  
10           INSERT INTO test_forall VALUES v_table(idx);   
11           --VALUES(v_table(idx).user_id,v_table(idx).user_name);Error   
12           --在PL/SQL中,BULK In-BIND与RECORDQ?ROWTYPE是不能在一块用的Q?nbsp;  
13           --也就是说QBULK In-BIND只能与简单类型的数组一块?nbsp;  
14    COMMIT;   
15  
16EXCEPTION   
17    WHEN OTHERS THEN  
18        ROLLBACK;   
19     
20END;  
21

fetch into 中用bulk collect
 1DECLARE
 2  TYPE table_forall IS TABLE OF test_forall%ROWTYPE;
 3  v_table table_forall;   
 4  
 5  CURSOR c1 IS
 6    SELECT mub.user_id,mub.user_name
 7         FROM mag_user_basic mub
 8           WHERE mub.user_id BETWEEN 10000 AND 10100;
 9BEGIN
10   OPEN c1;
11   --在fetch into中用bulk collect
12   FETCH c1 BULK COLLECT INTO v_table;
13   
14   FORALL idx IN 1..v_table.COUNT
15         INSERT INTO test_forall VALUES v_table(idx);
16    COMMIT;
17
18EXCEPTION
19    WHEN OTHERS THEN
20        ROLLBACK;
21END;

在returning into中用bulk collect
 1CREATE TABLE test_forall2 AS SELECT * FROM test_forall;
 2----在returning into中用bulk collect

 3DECLARE
 4   TYPE IdList IS TABLE OF test_forall.User_Id%TYPE;
 5
   enums IdList;
 6   TYPE NameList IS TABLE OF test_forall.user_name%
TYPE;
 7
   names NameList;
 8BEGIN

 9   DELETE FROM test_forall2 WHERE user_id = 10100
10        RETURNING user_iduser_name BULK COLLECT INTO enums, names;
11   dbms_output.put_line('Deleted ' || SQL%ROWCOUNT || ' rows:'
);
12   FOR i IN
 enums.FIRST .. enums.LAST
13
   LOOP
14     dbms_output.put_line('User #' || enums(i) || '' ||
 names(i));
15   END
 LOOP;
16   COMMIT
;
17
   
18
EXCEPTION
19    WHEN OTHERS THEN

20        ROLLBACK;
21
       
22END;

扚w更新中,forҎforall
 1DECLARE 
 2    TYPE NumList IS VARRAY(20OF NUMBER
;                                                
 3    depts NumList := NumList(103070
);
 4 -- department numbers                    

 5     BEGIN        
 6
                
 7       FOR i IN
 depts.FIRST..depts.LAST
 8
       LOOP
 9
       
10       --UPDATE statement is sent to the SQL engine 

11       -- with each iteration of the FOR loop!
12         UPDATE emp SET sal = sal * 1.10 WHERE deptno = depts(i);
13      END
 LOOP: 
14    END;          

1--UPDATE statement is sent to the SQL engine just once, with the entire nested table
2FORALL i IN depts.FIRST..depts.LAST 
3  UPDATE emp SET sal = sal * 1.10 WHERE deptno = depts(i); 

 To maximize performance, rewrite your programs as follows:
a. If an INSERT, UPDATE, or DELETE statement executes inside a loop and References collection elements, move it into a FORALL statement.
b. If a SELECT INTO, FETCH INTO, or RETURNING INTO clause references a
Collection, incorporate the BULK COLLECT clause.
c. If possible, use host arrays to pass collections back and forth between your Programs and the database server.
d. If the failure of a DML operation on a particular row is not a serious problem,Include the keywords SAVE EXCEPTIONS in the FORALL statement and report Or clean up the errors in a subsequent loop using the %BULK_EXCEPTIONS Attribute.


2011-08-22 12:55 发表评论
]]>
oracle查看表分区情况sqlhttp://www.aygfsteel.com/orangehf/archive/2011/08/10/356249.htmlWed, 10 Aug 2011 08:38:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/08/10/356249.htmlhttp://www.aygfsteel.com/orangehf/comments/356249.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/08/10/356249.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/356249.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/356249.html

select * from user_tab_subpartitions t where t.table_name = upper('tablename');
select * from user_tab_partitions t where t.table_name = upper('tablename');

 



2011-08-10 16:38 发表评论
]]>
oracle存储q程被锁定的解决Ҏhttp://www.aygfsteel.com/orangehf/archive/2011/08/04/355815.htmlThu, 04 Aug 2011 09:13:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/08/04/355815.htmlhttp://www.aygfsteel.com/orangehf/comments/355815.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/08/04/355815.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/355815.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/355815.html
2.若该存储q程q被锁定Q用sysd数据库,执行如下语句Q得到进Eid
select spid from
sys.v$process p, sys.v$session s
where p.addr = s.paddr
and s.status='KILLED'

3.在OS下kill掉这个进E?br />kill -9 14936

2011-08-04 17:13 发表评论
]]>
Oracle牛hbloghttp://www.aygfsteel.com/orangehf/archive/2011/08/03/355675.htmlWed, 03 Aug 2011 07:10:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/08/03/355675.htmlhttp://www.aygfsteel.com/orangehf/comments/355675.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/08/03/355675.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/355675.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/355675.htmlhttp://blog.csdn.net/tianlesoftware

2011-08-03 15:10 发表评论
]]>
Oracle delete执行q程的流E介l?/title><link>http://www.aygfsteel.com/orangehf/archive/2011/07/26/355052.html</link><dc:creator>南</dc:creator><author>南</author><pubDate>Tue, 26 Jul 2011 04:47:00 GMT</pubDate><guid>http://www.aygfsteel.com/orangehf/archive/2011/07/26/355052.html</guid><wfw:comment>http://www.aygfsteel.com/orangehf/comments/355052.html</wfw:comment><comments>http://www.aygfsteel.com/orangehf/archive/2011/07/26/355052.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/orangehf/comments/commentRss/355052.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/orangehf/services/trackbacks/355052.html</trackback:ping><description><![CDATA[<p>转自Q?a >http://database.51cto.com/art/201004/196771.htm</a><br /><br />以下的文章主要介l的?a ><font color="#004276">Oracle delete</font></a>的执行过E?我们大家都知道Oracle delete与Commit的实际操作的相关程的具体分析,以下是对其实际的操作流E的介绍Q望你在览之后会有所收获?/p> <p>Q?Q删除(deleteQ流E?/p> <p>Oracle读Block(数据?到Buffer CacheQ缓冲区Q?如果该Block在Buffer中不存在)Q?/p> <p>在Redo Log BufferQ重做日志缓冲区Q中记录Oracledelete操作的细节;</p> <p>在相应回滚段D头的事物表中创Z个UndoQ回滚)条目Q?/p> <p>把将要删除的记录创徏前镜像,存放到Undo BlockQ回滚块Q中Q?/p> <p>在Buffer Cache中的相应数据块上删除记录Qƈ且标记相应的数据块ؓDirtyQ脏Q?/p> <p>Q?Q提?Commit)程</p> <p>Oracle产生一个SCNQ?/p> <p>在回滚段事物表中标记该事物状态ؓCommitedQ?/p> <p>LGWRQ日志读写进E)Flush Log Buffer到日志文Ӟ</p> <p>如果此时数据块仍然在Buffer Cache中,那么SCN被记录到Block Header上,q被UCؓ快速提交;</p> <p>如果Dirty Block已经被写回到盘Q那么下一个访问这个Block的进E将会自回滚D中获取该事物的状态,认该事物被提交。然后这个进E获得提交SCNq写回到Block Header上,q被UCؓ延迟块清除?/p><img src ="http://www.aygfsteel.com/orangehf/aggbug/355052.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/orangehf/" target="_blank">南</a> 2011-07-26 12:47 <a href="http://www.aygfsteel.com/orangehf/archive/2011/07/26/355052.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle的Nologging何时生效 ?扚winsert加蝲数据速度http://www.aygfsteel.com/orangehf/archive/2011/07/19/354639.htmlTue, 19 Jul 2011 08:09:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/07/19/354639.htmlhttp://www.aygfsteel.com/orangehf/comments/354639.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/07/19/354639.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/354639.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/354639.html

转自Q?a href="http://www.aygfsteel.com/caizh2009/articles/306531.html">http://www.aygfsteel.com/caizh2009/articles/306531.html

一 非归档模式下

D:>sqlplus "/ as sysdba"

数据库版本ؓ9.2.0.1.0

SQL*Plus: Release 9.2.0.1.0 - Production on 星期一 8?14 10:20:39 2006

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.



q接?
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

当前session产生的redo
SQL> create or replace view redo_size
2 as
3 select value
4 from v$mystat, v$statname
5 where v$mystat.statistic# = v$statname.statistic#
6 and v$statname.name = 'redo size';

视图已徏立?/font>

授权l相应数据库schema
SQL> grant select on redo_size to liyong;

授权成功?/font>

SQL> shutdown immediate;
数据库已l关闭?br />已经卸蝲数据库?br />ORACLE 例程已经关闭?/font>

SQL> startup mount;
ORACLE 例程已经启动?/font>

Total System Global Area 122755896 bytes
Fixed Size 453432 bytes
Variable Size 88080384 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
数据库装载完毕?/font>

非归档模?br />SQL> alter database noarchivelog;

数据库已更改?/font>

SQL> alter database open;

数据库已更改?/font>

SQL> create table redo_test as
2 select * from all_objects where 1=2;

表已创徏?/font>

SQL> select * from sys.redo_size;

VALUE
----------
59488

SQL> insert into redo_test
2 select * from all_objects;

已创?8260行?/font>

SQL> select * from sys.redo_size;

VALUE
----------
3446080

SQL> insert /*+ append */ into redo_test
2 select * from all_objects;

已创?8260行?/font>

SQL> commit;

提交完成?/font>

SQL> select * from sys.redo_size;

VALUE
----------
3458156

可以看到insert /*+ append */ into方式redo产生很少.
SQL> select 3446080-59488,3458156-3446080 from dual;

3446080-59488 3458156-3446080
------------- ---------------
3386592 12076

表redo_test|ؓnologging状?
SQL> alter table redo_test nologging;

表已更改?/font>

SQL> select * from sys.redo_size;

VALUE
----------
3460052

SQL> insert into redo_test
2 select * from all_objects;

已创?8260行?/font>

SQL> commit;

提交完成?/font>

SQL> select * from sys.redo_size;

VALUE
----------
6805876

SQL> insert /*+ append */ into redo_test
2 select * from all_objects;

已创?8260行?/font>

SQL> commit;

提交完成?/font>

SQL> select * from sys.redo_size;

VALUE
----------
6818144

非归档模式下表的nologging状态对于redo影响不大
SQL> select 6805876-3460052,6818144-6805876 from dual;

6805876-3460052 6818144-6805876
--------------- ---------------
3345824 12268


l论: 在非归档模式下通过insert /*+ append */ into方式扚w加蝲数据可以大大减少redo产生.

?归档模式?/font>


SQL> shutdown immediate;
数据库已l关闭?br />已经卸蝲数据库?br />ORACLE 例程已经关闭?br />SQL> startup mount;
ORACLE 例程已经启动?/font>

Total System Global Area 122755896 bytes
Fixed Size 453432 bytes
Variable Size 88080384 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
数据库装载完毕?br />SQL> alter database archivelog;

数据库已更改?/font>

SQL> alter database open;

数据库已更改?/font>

SQL> conn liyong
误入口?
已连接?/font>


表redo_test重新|ؓlogging
SQL> alter table redo_test logging;

表已更改?/font>

SQL> select * from sys.redo_size;

VALUE
----------
5172

SQL> insert into redo_test
2 select * from all_objects;

已创?8260行?/font>

SQL> commit;

提交完成?/font>

SQL> select * from sys.redo_size;

VALUE
----------
3351344

SQL> insert /*+ append */ into redo_test
2 select * from all_objects;

已创?8260行?/font>

SQL> commit;

提交完成?/font>

SQL> select * from sys.redo_size;

VALUE
----------
6659932

可以看到在归档模式下Q且表的logging属性ؓtrue,insert /*+ append */ intoq种方式也会U录大量redo
SQL> select 3351344-5172,6659932-3351344 from dual;

3351344-5172 6659932-3351344
------------ ---------------
3346172 3308588


表|ؓnologging

SQL> alter table redo_test nologging;

表已更改?/font>

SQL> select * from sys.redo_size;

VALUE
----------
6661820

SQL> insert into redo_test
2 select * from all_objects;

已创?8260行?/font>

SQL> commit;

提交完成?/font>

SQL> select * from sys.redo_size;

VALUE
----------
10008060

SQL> insert /*+ append */ into redo_test
2 select * from all_objects;

已创?8260行?/font>

SQL> commit;

提交完成?/font>

SQL> select * from sys.redo_size;

VALUE
----------
10022852

可以发现在归档模式,要设|表的logging属性ؓfalseQ才能通过insert /*+ append */ into大大减少redo产生.
SQL> select 10008060-6661820,10022852-10008060 from dual;

10008060-6661820 10022852-10008060
---------------- -----------------
3346240 14792

l论: 在归档模式下,要设|表的logging属性ؓfalseQ?br />才能通过insert /*+ append */ into大大减少redo.

?下面我们再看一下在归档模式下,几种扚winsert操作的效率对?

redo_test表有45W条记?/font>

SQL> select count(*) from redo_test;

COUNT(*)
----------
452160


1 最常见的批量数据加?25U?/font>

SQL> create table insert_normal as
2 select * from redo_test where 0=2;

表已创徏?/font>

SQL> set timing on

SQL> insert into insert_normal
2 select * from redo_test;

已创?52160行?/font>

提交完成?br />已用旉: 00: 00: 25.00


2 使用insert /*+ append */ into方式(q个的原理可以参?lt;<扚wDML操作优化.txt>>)Q但U录redo. 17.07U?br />SQL> create table insert_hwt
2 as
3 select * from redo_test where 0=2;

表已创徏?br />SQL> insert /*+ append */ into insert_hwt
2 select * from redo_test;

已创?52160行?/font>

提交完成?br />已用旉: 00: 00: 17.07


3 使用insert /*+ append */ into方式Q且通过讄表nologging不纪录redo.

SQL> create table insert_hwt_with_nologging nologging
2 as
3 select * from redo_test where 2=0;

表已创徏?/font>

/*
或者通过
alter table table_name nologging讄
*/

SQL> insert /*+ append */ into insert_hwt_with_nologging 11.03U?br />2 select * from redo_test;

已创?52160行?/font>

提交完成?br />已用旉: 00: 00: 11.03

ȝ:

我们看到对于扚w操作Q如果设|表nologgingQ可以大大提高性能.原因是Oracle没有U录DML所产生的redo.
当然Q这样会影响到备份。nologging加蝲数据后要做数据库全备.
--------------------------------------------------------------------------------------------------------------------------------


jolly10 发表?2008.03.18 13:19 ::分类: ( 转蝲学习内容 ) ::阅读:(1097? :: 评论 (3) :: 引用 (0)
re: Oracle的Nologging何时生效 ?扚winsert加蝲数据速度(zt) [回复]

下面我又试了试insert into XXX values (XXX)能不能少产生redo,做了试验发现,不行?下面的过E?
SQL> select * from v$version where rownum archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 17
Current log sequence 19

SQL> create or replace view redo_size
2 as
3 select value
4 from v$mystat, v$statname
5 where v$mystat.statistic# = v$statname.statistic#
6 and v$statname.name = 'redo size';

View created.

SQL> grant select on redo_size to ljg;

SQL> conn ljg/ljg
Connected.

SQL> create table redo_test as
2 select * from all_objects where 1=2;

SQL> CREATE OR REPLACE PROCEDURE p_loging
2 as
3 CURSOR c_a IS
4 SELECT * FROM all_objects;
5
6 BEGIN
7 FOR x IN c_a LOOP
8 INSERT INTO REDO_TEST
9 VALUES(x.OWNER, x.OBJECT_NAME, x.SUBOBJECT_NAME, x.OBJECT_ID, x.DATA_OBJE CT_ID,
10 x.OBJECT_TYPE, x.CREATED, x.LAST_DDL_TIME, x.TIMESTAMP, x.STATUS, x.TEMPORARY, x.GENERATED, x.SECONDARY);
11 END LOOP;
12 COMMIT;
13
14 END;
15 /

Procedure created.

SQL> CREATE OR REPLACE PROCEDURE p_nologing
2 as
3 CURSOR c_a IS
4 SELECT * FROM all_objects;
5
6 BEGIN
7 FOR x IN c_a LOOP
8 INSERT /*+ APPEND */ INTO REDO_TEST
9 VALUES(x.OWNER, x.OBJECT_NAME, x.SUBOBJECT_NAME, x.OBJECT_ID, x.DATA_OBJECT_ID,
10 x.OBJECT_TYPE, x.CREATED, x.LAST_DDL_TIME, x.TIMESTAMP, x.STATUS, x.TEMPORARY, x.GENERATED, x.SECONDARY);
11 END LOOP;
12 COMMIT;
13
14 END;
15 /

Procedure created.

SQL> select * from sys.redo_size;

VALUE
----------
85940

SQL> exec p_loging;

PL/SQL procedure successfully completed.

SQL> select * from sys.redo_size;

VALUE
----------
15273968

SQL> exec p_nologing;

PL/SQL procedure successfully completed.

SQL> select * from sys.redo_size;

VALUE
----------
30411272

SQL> select 15273968- 85940 logging,30411272-15273968 nologging from dual;

LOGGING NOLOGGING
---------- ----------
15188028 15137304

可以看到nologging和logging产生的redo差不?

jolly10 评论于:2008.06.05 11:07
re: Oracle的Nologging何时生效 ?扚winsert加蝲数据速度(zt) [回复]

下面我又试了试insert into XXX values (XXX)能不能少产生redo,做了试验发现,不行?下面的过E?
SQL> select * from v$version where rownum archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 17
Current log sequence 19

SQL> create or replace view redo_size
2 as
3 select value
4 from v$mystat, v$statname
5 where v$mystat.statistic# = v$statname.statistic#
6 and v$statname.name = 'redo size';

View created.

SQL> grant select on redo_size to ljg;

SQL> conn ljg/ljg
Connected.

SQL> create table redo_test as
2 select * from all_objects where 1=2;

SQL> CREATE OR REPLACE PROCEDURE p_loging
2 as
3 CURSOR c_a IS
4 SELECT * FROM all_objects;
5
6 BEGIN
7 FOR x IN c_a LOOP
8 INSERT INTO REDO_TEST
9 VALUES(x.OWNER, x.OBJECT_NAME, x.SUBOBJECT_NAME, x.OBJECT_ID, x.DATA_OBJE CT_ID,
10 x.OBJECT_TYPE, x.CREATED, x.LAST_DDL_TIME, x.TIMESTAMP, x.STATUS, x.TEMPORARY, x.GENERATED, x.SECONDARY);
11 END LOOP;
12 COMMIT;
13
14 END;
15 /

Procedure created.

SQL> CREATE OR REPLACE PROCEDURE p_nologing
2 as
3 CURSOR c_a IS
4 SELECT * FROM all_objects;
5
6 BEGIN
7 FOR x IN c_a LOOP
8 INSERT /*+ APPEND */ INTO REDO_TEST
9 VALUES(x.OWNER, x.OBJECT_NAME, x.SUBOBJECT_NAME, x.OBJECT_ID, x.DATA_OBJECT_ID,
10 x.OBJECT_TYPE, x.CREATED, x.LAST_DDL_TIME, x.TIMESTAMP, x.STATUS, x.TEMPORARY, x.GENERATED, x.SECONDARY);
11 END LOOP;
12 COMMIT;
13
14 END;
15 /

Procedure created.

SQL> select * from sys.redo_size;

VALUE
----------
85940

SQL> exec p_loging;

PL/SQL procedure successfully completed.

SQL> select * from sys.redo_size;

VALUE
----------
15273968

SQL> exec p_nologing;

PL/SQL procedure successfully completed.

SQL> select * from sys.redo_size;

VALUE
----------
30411272

SQL> select 15273968- 85940 logging,30411272-15273968 nologging from dual;

LOGGING NOLOGGING
---------- ----------
15188028 15137304

可以看到nologging和logging产生的redo差不?

jolly10 评论于:2008.06.05 11:07
re: Oracle的Nologging何时生效 ?扚winsert加蝲数据速度(zt) [回复]

在ITPUB中问到可以用BULK COLLECT 来减insert into values的redo.
CREATE OR REPLACE PROCEDURE p_BulkAdd
AS
TYPE Tredo_test IS TABLE OF REDO_TEST%ROWTYPE;
V_REDO_TEST Tredo_test;
BEGIN
SELECT * BULK COLLECT INTO V_REDO_TEST FROM ALL_OBJECTS;
FORALL X IN V_REDO_TEST.FIRST..V_REDO_TEST.LAST
INSERT INTO REDO_TEST VALUES V_REDO_TEST(X);
END;
/

SQL> select * from sys.redo_size;

VALUE
----------
30411272

SQL> exec p_bulkadd;

PL/SQL procedure successfully completed.

SQL> select * from sys.redo_size;

VALUE
----------
35050796

SQL> select 35050796-30411272 from dual;

35050796-30411272
-----------------
4639524

q个做的是了很多redo.是一个方?



2011-07-19 16:09 发表评论
]]>
oracle分区索引Q局?locally & 全局 globalhttp://www.aygfsteel.com/orangehf/archive/2011/07/07/353874.htmlThu, 07 Jul 2011 07:02:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/07/07/353874.htmlhttp://www.aygfsteel.com/orangehf/comments/353874.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/07/07/353874.html#Feedback3http://www.aygfsteel.com/orangehf/comments/commentRss/353874.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/353874.html表可以按rangeQhashQlist分区Q表分区后,其上的烦引和普通表上的索引有所不同Qoracle对于分区表上的烦引分?c,卛_部烦引和全局索引Q下面分别对q?U烦引的特点和局限性做个ȝ?/strong>

 

局部烦引local index

1.        局部烦引一定是分区索引Q分区键{同于表的分区键Q分区数{同于表的分Q一句话Q局部烦引的分区机制和表的分区机制一栗?/p>

2.        如果局部烦引的索引列以分区键开_则称为前~局部烦引?/p>

3.        如果局部烦引的列不是以分区键开_或者不包含分区键列Q则UCؓ非前~索引?/p>

4.        前缀和非前缀索引都可以支持烦引分区消除,前提是查询的条g中包含烦引分区键?/p>

5.        局部烦引只支持分区内的唯一性,无法支持表上的唯一性,因此如果要用局部烦引去l表做唯一性约束,则约束中必须要包括分区键?br />           (ALTER TABLE TEST ADD CONSTRAINT PK_TEST PRIMARY KEY (SEQ_ID,PARTITION_ID) USING INDEX LOCAL;)?/p>

6.        局部分区烦引是对单个分区的Q每个分区烦引只指向一个表分区Q全局索引则不Ӟ一个分区烦引能指向n个表分区Q同Ӟ一个表分区Q也可能指向n个烦引分区,对分中的某个分区做truncate或者moveQshrink{,可能会媄响到n个全局索引分区Q正因ؓq点Q局部分区烦引具有更高的可用性?/p>

7.        位图索引只能为局部分区烦引?/p>

8.        局部烦引多应用于数据仓库环境中?/p>

 

全局索引global index

1.        全局索引的分区键和分区数和表的分区键和分区数可能都不相同Q表和全局索引的分区机制不一栗?/p>

2.        全局索引可以分区Q也可以是不分区索引Q全局索引必须是前~索引Q即全局索引的烦引列必须是以索引分区键作为其前几列?/p>

3.        全局分区索引的烦引条目可能指向若q个分区Q因此,对于全局分区索引Q即使只

动,截断一个分Z的数据,都需要rebulid若干个分区甚

x整个索引?/p>

4.        全局索引多应用于oltppȝ中?/p>

5.        全局分区索引只按范围或者散列hash分区Qhash分区?0g以后才支持?/p>

6.        oracle9i以后对分做move或者truncate的时可以用update global indexes语句来同步更新全局分区索引Q用消耗一定资源来换取高度的可用性?/p>

7.        表用a列作分区Q烦引用b做局部分区烦引,若where条g中用b来查询,那么oracle会扫描所有的表和索引的分区,成本会比分区更高Q此时可以考虑用b做全局分区索引?/p>

 

分区索引字典

 

DBA_PART_INDEXES 分区索引的概要统计信息,可以得知每个表上有哪些分区烦引,分区索引的类?local/global,)

Dba_ind_partitions每个分区索引的分区l计信息

Dba_indexesminusdba_part_indexesQ可以得到每个表上有哪些非分区烦?/p>

 

索引重徏

 

Alter index idx_name rebuild partition index_partition_name [online nologging]

需要对每个分区索引做rebuildQ重建的时候可以选择online(不会锁定?,或者nologging建立索引的时候不生成日志Q加快速度?/p>

Alter index rebuild idx_name [online nologging]

寚w分区索引Q只能整个index重徏

转自
http://www.csharpwin.com/dotnetspace/8650r3516.shtml
http://hi.baidu.com/wxf966/blog/item/77954d074469e4df7a894700.html



2011-07-07 15:02 发表评论
]]>
Oracle中,什么是High-warter markQHWMQ?/title><link>http://www.aygfsteel.com/orangehf/archive/2011/03/24/346959.html</link><dc:creator>南</dc:creator><author>南</author><pubDate>Thu, 24 Mar 2011 08:12:00 GMT</pubDate><guid>http://www.aygfsteel.com/orangehf/archive/2011/03/24/346959.html</guid><wfw:comment>http://www.aygfsteel.com/orangehf/comments/346959.html</wfw:comment><comments>http://www.aygfsteel.com/orangehf/archive/2011/03/24/346959.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/orangehf/comments/commentRss/346959.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/orangehf/services/trackbacks/346959.html</trackback:ping><description><![CDATA[<p>      在Oracle数据的存储中Q可以把存储I间惌Z个水库,数据惌为水库中的水。水库中的水的位|有一条线叫做水位U,在Oracle中,q条U被UCؓ高水位线QHigh-warter mark, HWMQ。在数据库表刚徏立的时候,׃没有M数据Q所以这个时候水位线是空的,也就是说HWM为最低倹{当插入了数据以后,高水位线׃上涨Q但是这里也有一个特性,是如果你采用delete语句删除数据的话Q数据虽然被删除了,但是高水位线却没有降低,q是你刚才删除数据以前那么高的水位。也是_q条高水位线在日常的增删操作中只会上涨,不会下跌?/p> <p><br />       下面我们来谈一下Oracle中Select语句的特性。Select语句会对表中的数据进行一ơ扫描,但是I竟扫描多少数据存储块呢Q这个ƈ不是说数据库中有多少数据QOracle扫描这么大的数据块Q而是Oracle会扫描高水位U以下的数据块。现在来惌一下,如果刚才是一张刚刚徏立的IQ你q行了一ơSelect操作Q那么由于高水位UHWM在最低的0位置上,所以没有数据块需要被扫描Q扫描时间会极短。而如果这个时候你首先插入了一千万条数据,然后再用delete语句删除q一千万条数据。由于插入了一千万条数据,所以这个时候的高水位线在一千万条数据这里。后来删除这一千万条数据的时候,׃delete语句不媄响高水位U,所以高水位U依然在一千万条数据这里。这个时候再一ơ用select语句q行扫描Q虽然这个时候表中没有数据,但是׃扫描是按照高水位U来的,所以需要把一千万条数据的存储I间都要扫描一ơ,也就是说q次扫描所需要的旉和扫描一千万条数据所需要的旉是一样多的。所以有时候有人Ll常_怎么我的表中没有几条数据Q但是还是这么慢呢,q个时候其实奥U就是这里的高水位线了?/p> <p><br />        那有没有办法让高水位U下降呢Q其实有一U比较简单的ҎQ那是采用TRUNCATE语句q行删除数据。采用TRUNCATE语句删除一个表的数据的时候,cM于重新徏立了表,不仅把数据都删除了,q把HWMl清I恢复ؓ0。所以如果需要把表清I,在有可能利用TRUNCATE语句来删除数据的时候就利用TRUNCATE语句来删除表Q特别是那种数据量有可能很大的时存储表?/p> <p><br />         在手动段I间理QManual Segment Space ManagementQ中Q段中只有一个HWMQ但是在Oracle9iRelease1才添加的自动D늩间管理(Automatic Segment Space ManagementQ中Q又有了一个低HWM的概念出来。ؓ什么有了HWMq又有一个低HWM呢,q个是因动段I间理的特性造成的。在手段D늩间管理中Q当数据插入以后Q如果是插入到新的数据块中,数据块就会被自动格式化等待数据访问。而在自动D늩间管理中Q数据插入到新的数据块以后,数据块ƈ没有被格式化Q而是在第一ơ在W一ơ访问这个数据块的时候才格式化这个块。所以我们又需要一条水位线Q用来标C已l被格式化的块。这条水位线叫做低HWM。一般来_低HWM肯定是低于等于HWM的?/p> <img src ="http://www.aygfsteel.com/orangehf/aggbug/346959.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/orangehf/" target="_blank">南</a> 2011-03-24 16:12 <a href="http://www.aygfsteel.com/orangehf/archive/2011/03/24/346959.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle中,什么是Rollback SegmentsQ?/title><link>http://www.aygfsteel.com/orangehf/archive/2011/03/24/346955.html</link><dc:creator>南</dc:creator><author>南</author><pubDate>Thu, 24 Mar 2011 08:03:00 GMT</pubDate><guid>http://www.aygfsteel.com/orangehf/archive/2011/03/24/346955.html</guid><wfw:comment>http://www.aygfsteel.com/orangehf/comments/346955.html</wfw:comment><comments>http://www.aygfsteel.com/orangehf/archive/2011/03/24/346955.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/orangehf/comments/commentRss/346955.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/orangehf/services/trackbacks/346955.html</trackback:ping><description><![CDATA[<p>Rollback Segments是在你数据库中的一些存储空_它用来时的保存当数据库数据发生改变时的先前|<br /> Rollback Segment主要有两个目的:<br /> <br /> 1. 如果因ؓ某种原因或者其他用用户惌通过ROLLBACK声明来取消一个h的数据操作,数据׃复原C前ؓ改变时的倹{这U情况只在transaction的过E中有效Q如果用h行了COMMIT命oQ那么ROLLBACK SEGMENT里面的值就会标识ؓ失效的,数据改变将怹化?br /> <br /> 2. 另一个目的是当有q发的session讉K了一个数据值改变但事务q没有提交的表。如果一个SELECT语句开始读取一个表同时一个事务也在修改这个表的|那么修改前的值就会保存到rollback segment里面QSELECT语句也是从ROLLBACK SEGMENT里面d表的倹{?</p> <p> </p> <img src ="http://www.aygfsteel.com/orangehf/aggbug/346955.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/orangehf/" target="_blank">南</a> 2011-03-24 16:03 <a href="http://www.aygfsteel.com/orangehf/archive/2011/03/24/346955.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java?netq_之间q行RSA加密验证http://www.aygfsteel.com/orangehf/archive/2011/02/26/345243.htmlSat, 26 Feb 2011 09:00:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/02/26/345243.htmlhttp://www.aygfsteel.com/orangehf/comments/345243.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/02/26/345243.html#Feedback2http://www.aygfsteel.com/orangehf/comments/commentRss/345243.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/345243.html阅读全文

2011-02-26 17:00 发表评论
]]>
linux下用crond定时执行kettle的jobhttp://www.aygfsteel.com/orangehf/archive/2011/02/11/344045.htmlFri, 11 Feb 2011 04:13:00 GMThttp://www.aygfsteel.com/orangehf/archive/2011/02/11/344045.htmlhttp://www.aygfsteel.com/orangehf/comments/344045.htmlhttp://www.aygfsteel.com/orangehf/archive/2011/02/11/344045.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/344045.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/344045.html׃W一ơ碰linuxQ对其不是很了解Q导致这个问题困C我近一个月的时_现在l于解决了,分nl大家?br />  
首先Q安装jreQ配|java环境变量
 
(一)   下蝲jre-6u23-linux-x64.bin

下蝲地址Q?/span>http://cds-esd.sun.com/ESD6/JSCDL/jdk/6u23-b05/jre-6u23-linux-x64.bin?AuthParam=1292401739_2abc6c61c57eec5b100fe647086d1f33&TicketId=CJ0nhpzNkjGGwpbkW40LAgA%3D&GroupName=CDS&FilePath=/ESD6/JSCDL/jdk/6u23-b05/jre-6u23-linux-x64.bin&File=jre-6u23-linux-x64.bin

(?   安装jre-6u23-linux-x64.bin

      ?/span>jre-6u23-linux-x64.bin上传?/span>linux服务?/span>

1.     在终端上Q键入:
su

2.     输入用户口o?/span>

3.     切换到所需的安装目录。类型:
cd <
目录路径?/span>>
例如Q要?/span> /usr/java/ 目录中安装YӞ请键入:
cd /usr/java/

关于用户讉K权限的说明:要将 JRE 安装在系l位置Q例?/span> /usr/localQ,必须以超U用戯n份登录,从而获得必要的权限。如果您不具有超U用戯问权限,请将 JRE 安装在您的主目录中,或者安装在您具有写入权限的子目录中?/span>

4.     您下蝲的文件的权限更改为可执行。类型:
chmod a+x jre-6u23-linux-x64.bin

5.      启动安装q程。键入:
./ jre-6u23-linux-x64.bin

此时显CZq制许可协议。通读许可协议。按I格键显CZ一c读完许可协议后Q输?/span> yes l箋安装Q此步骤可能直接跌Q?/strong>?/span>

7.     JRE 安装在其自n的目录中。在本例中,它将安装?/span> /usr/java/ jre1.6.0_23目录中。当安装完成Ӟ您将看到 DoneQ完成)字样?br />

 (?   配置java环境变量

1.     命o行键?#8220;cd /etcq入etc目录

2.     命o行键?#8220;vi profile打开profile文g

3.     敲击键盘ctrl+F到文件末?br />

4.     在末֤Q即W一?/span>~的地方,敲击键盘以下内容输入到文g

JAVA_HOME=/usr/java/jre1.6.0_23

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME

export PATH

export CLASSPATH

     5.     键盘敲击excQ命令行键入“:wq”Q保存文Ӟ

     6.     重新dlinuxQ在命o行键?#8220;java”Q如果出现帮助信息则表示配置成功?/span>


然后Q部|kettle

       
1.         ?/span>pdi-ce-4.1.0-stable.zip上传?/span>linux服务?/span>

2.         使用unzip命o解压pdi-ce-4.1.0-stable.zip
unzip pdi-ce-4.1.0-stable.zip -d "/mnt/kettle"

3.         赋予解压目录?/span>.sh文g的执行权?/span>

chmod +x *.sh

4.         q入解压目录Q键?#8220;./kitchen.sh”回RQ如果有帮助信息则表C?/span>kettle环境部v成功


※(重点Q接着Q编写执行kettled的shell脚本

创徏test.shQ将以下内容复制_脓到里面,然后键入“chmod +x /mnt/kettle/*.sh”Q赋予test.sh执行权限?/p>

export JAVA_HOME=/usr/java/jre1.6.0_23
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
/mnt/kettle/data-integration/kitchen.sh -file=/mnt/kettle/test.kjb > /mnt/kettle/display.txt


说明Q?br /> ?行,讄java环境变量的语句必不可,
因ؓcrond是个守护q程Q它不归属于M用户Q虽然之前以rootw䆾配置了java的环境变量,但是crond一h不到java命oQ?br /> 所以,当crond执行kettledӞ需要动态设|java环境变量Qcrond才能扑ֈjava命o?/span>


最后,使用crontab命od定时d

       1.在终端上Q键?#8220;crontab -e”Q进入定时Q务文?br />        2.键入“a”Q对文gq行~辑
          输入如下内容Q?nbsp;
23 11 10 02 * /mnt/kettle/test.sh
        其中 23为分钟,11为小Ӟ10为日Q?2为月Q?为星期几Qcrontab命o的用这里不再赘q?br />        3.键盘敲击excQ终端键?#8220;:wq”Q保存文?br />        4.重启crond服务
          键入“cd /etc/init.d”Q进入该目录
          键入“./crond restart”Q重启crond服务
      5.{待执行l果
      6.执行成功Qoh..nice!

2011-02-11 12:13 发表评论
]]>
c# 正则表达?group 高用法http://www.aygfsteel.com/orangehf/archive/2009/11/11/301958.htmlWed, 11 Nov 2009 05:40:00 GMThttp://www.aygfsteel.com/orangehf/archive/2009/11/11/301958.htmlhttp://www.aygfsteel.com/orangehf/comments/301958.htmlhttp://www.aygfsteel.com/orangehf/archive/2009/11/11/301958.html#Feedback1http://www.aygfsteel.com/orangehf/comments/commentRss/301958.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/301958.html 

 1            string strText = "中国沛_省石家庄?/span>";
 2            // 要用key的功能,需要这样写?<prov>Q??"必须加)Q?prov"为key名称
 3            Regex oRegex = new Regex(@"(中国)*(?<prov>.+?(?<city>.+?");
 4
 5            MatchCollection oMatchCollection = oRegex.Matches(strText);
 6
 7            foreach (Match oMatch in oMatchCollection)
 8            {
 9                // 取值的时候就用正则表辑ּ里的key取?/span>
10                MessageBox.Show(oMatch.Groups["prov"+ "----" + oMatch.Groups["city"]);
11            }
 
很好用!强力推荐Q?/strong>

2009-11-11 13:40 发表评论
]]>
An Introduction in MSMQ(Microsoft Message Queue)http://www.aygfsteel.com/orangehf/archive/2009/04/11/265041.htmlSat, 11 Apr 2009 11:34:00 GMThttp://www.aygfsteel.com/orangehf/archive/2009/04/11/265041.htmlhttp://www.aygfsteel.com/orangehf/comments/265041.htmlhttp://www.aygfsteel.com/orangehf/archive/2009/04/11/265041.html#Feedback0http://www.aygfsteel.com/orangehf/comments/commentRss/265041.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/265041.html阅读全文

2009-04-11 19:34 发表评论
]]>
游?-贪食?-C#--源代?/title><link>http://www.aygfsteel.com/orangehf/archive/2008/10/05/232524.html</link><dc:creator>南</dc:creator><author>南</author><pubDate>Sun, 05 Oct 2008 08:16:00 GMT</pubDate><guid>http://www.aygfsteel.com/orangehf/archive/2008/10/05/232524.html</guid><wfw:comment>http://www.aygfsteel.com/orangehf/comments/232524.html</wfw:comment><comments>http://www.aygfsteel.com/orangehf/archive/2008/10/05/232524.html#Feedback</comments><slash:comments>12</slash:comments><wfw:commentRss>http://www.aygfsteel.com/orangehf/comments/commentRss/232524.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/orangehf/services/trackbacks/232524.html</trackback:ping><description><![CDATA[<p>        好不Ҏ有个十一长假Q终于可以编点自己喜Ƣ的东西了,׃公司主要用的是C#Q我也就入乡随俗了,拿C#写了个小游戏l练手,以后有时间再用JAVA重写一遍?br /> <br />         q只是初版,如果有BUG的话Q大家尽量提出来噢,我会力改的Q不会改的就得请教各位高手咯Q?br /> 我同时也希望可以帮助像我一L初学者能更上一层楼 ?br /> <br />         q有一个我不解的问题,希望高手赐教?br /> <br />         <span style="color: #ff6600">当我在Visual Studio 2005里点q行按钮Ӟ游戏q行会很卡,很占CPUQ而且源代码目录下会生成一大堆.TMP文gQ但是,我直接双击DEBUG文g夹下~译好的.exe文gQ游戏运行正常,CPU占用率很?/span><span style="color: #ff6600">?br /> </span><br />         谁能告诉我ؓ什么?先谢谢啦Q?br /> <br />         以下是可执行文g及源代码的下?br />         <a href="/Files/orangehf/MySnake.rar">MySnake</a><br />                                                                                                                                                                                08.10.05<br /> <hr />         今天修复了一个BUGQ即在定时器每次旉间隔中,可以改变Nơ蛇的移动方向,只要按的够快。这样就产生了一个问题,比如_蛇正在向右移动,用很快的手速依ơ按?↓"键和"←"键,当按?↓"键时Q蛇实际q没有移动(每次旉间隔只能Ud一ơ)Q但Ud方向已改变ؓ下,q时可以按下"←"键的条g为真Q按?←"键后在界面显Cq未Ud的情况下Q就GAME OVER了(卌头撞C蛇nQ?br /> <p><br />         我在原有基础上加了个BOOL变量canChangeDirectionQ来控制在定时器每次旉间隔中,只能改变一ơ蛇的移动方向,q样׃复了以上BUG?br /> <br />         以下?.01版本的可执行文g及源代码的下?br />         <a href="/Files/orangehf/MySnake_v1.01.rar">MySnake_v1.01</a></p>                                                                                                                                                                                 08.10.12<br />   <hr />       今天又修改了两个地方Q这都要多亏<a id="AjaxHolder_Comments_CommentList_ctl02_NameLink" target="_blank">raof01</a> l我提的两个很好的徏议。在q里要好好谢谢他Q?br /> <br />       1.原来蛇nUd的算法效率不高,我的做法是先移动前的整个蛇w坐标复制一遍,然后再进行移动时的赋|其实只要复制当前Tile的前一个Tile的坐标即可,详情误v1.02版的代码?br /> <br />       2.在v1.01版中Q不支持在每个时间间隔内玩家多次的键盘输入,x个时间间隔内只接受玩家的W一ơ输入,其实q样很不人性化Q通过<a id="AjaxHolder_Comments_CommentList_ctl02_NameLink" target="_blank">raof01</a> 的指点,我在v1.02版中d了一个保存蛇的移动方向的队列Q存储用L输入Q这L家想按多快都可以了,他按的都会被处理Q按照队列的序依次改变蛇的Ud方向Q不q每个时间间隔依然只能改变一ơ移动方向?br /> <br />       以下?.02版本的可执行文g及源代码的下?br />       <a href="/Files/orangehf/MySnake_v1.02.rar">MySnake_v1.02</a><a href="/Files/orangehf/MySnake_v1.02.rar"><br /> </a>                                                                                                                                                                                08.10.18<br /> <img src ="http://www.aygfsteel.com/orangehf/aggbug/232524.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/orangehf/" target="_blank">南</a> 2008-10-05 16:16 <a href="http://www.aygfsteel.com/orangehf/archive/2008/10/05/232524.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>strictfp关键字具体有什么用处呢?http://www.aygfsteel.com/orangehf/archive/2007/10/21/154679.htmlSun, 21 Oct 2007 05:05:00 GMThttp://www.aygfsteel.com/orangehf/archive/2007/10/21/154679.htmlhttp://www.aygfsteel.com/orangehf/comments/154679.htmlhttp://www.aygfsteel.com/orangehf/archive/2007/10/21/154679.html#Feedback1http://www.aygfsteel.com/orangehf/comments/commentRss/154679.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/154679.html
了解了strictfp的意思是FP-strictQ也是说精Q点的意?当一个class或interface用strictfp声明Q内部所有的float和double表达式都会成为strictfp?W合IEEE-754规范.

q说如果你想让你的Q点运更加精,而且不会因ؓ不同的硬件^台所执行的结果不一致的话,那就L关键字strictfp.

但我试验了一?即ɾl类加了strictfp关键?q是得不到精结果啊..

代码如下:
public strictfp class TestStrictfp {

    
/**
     * 
@param args
     
*/


    
public static void main(String[] args) {

        
float a = (float1.03;
        
float b = (float) .42;
        
        
double c = 1.03;
        
double d = .42;
        
        System.out.println(a 
* b);
        System.out.println(c 
- d);
        
    }


}

请问strictfp关键字到底用在什么地方呢?最好给个实例哈~



2007-10-21 13:05 发表评论
]]>
二进制与L字符互{程?/title><link>http://www.aygfsteel.com/orangehf/archive/2007/10/18/153810.html</link><dc:creator>南</dc:creator><author>南</author><pubDate>Thu, 18 Oct 2007 03:42:00 GMT</pubDate><guid>http://www.aygfsteel.com/orangehf/archive/2007/10/18/153810.html</guid><wfw:comment>http://www.aygfsteel.com/orangehf/comments/153810.html</wfw:comment><comments>http://www.aygfsteel.com/orangehf/archive/2007/10/18/153810.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.aygfsteel.com/orangehf/comments/commentRss/153810.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/orangehf/services/trackbacks/153810.html</trackback:ping><description><![CDATA[貌似在昨?偶看?a id="AjaxHolder_Comments_CommentList_ctl01_NameLink" href="http://www.aygfsteel.com/hmilyld/" target="_blank">Hmilyld</a>博里的一日志叫汉字转换Zq制的小工具,一个很不错的工?<br /> 看着看着,偶就手痒?于是我也写了一个二q制与Q意字W互转小E序,8q米界面?<br /> 代码很少<br /> <br /> 源代码如? <br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #000000"><br /> <img id="Codehighlighter1_28_2191_Open_Image" onclick="this.style.display='none'; Codehighlighter1_28_2191_Open_Text.style.display='none'; Codehighlighter1_28_2191_Closed_Image.style.display='inline'; Codehighlighter1_28_2191_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_28_2191_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_28_2191_Closed_Text.style.display='none'; Codehighlighter1_28_2191_Open_Image.style.display='inline'; Codehighlighter1_28_2191_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> StrBinaryTurn </span><span id="Codehighlighter1_28_2191_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_28_2191_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #008000">//</span><span style="color: #008000">字W串转换成二q制字符Ԍ以空格相?/span><span style="color: #008000"><br /> <img id="Codehighlighter1_88_277_Open_Image" onclick="this.style.display='none'; Codehighlighter1_88_277_Open_Text.style.display='none'; Codehighlighter1_88_277_Closed_Image.style.display='inline'; Codehighlighter1_88_277_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_88_277_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_88_277_Closed_Text.style.display='none'; Codehighlighter1_88_277_Open_Image.style.display='inline'; Codehighlighter1_88_277_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" /></span><span style="color: #000000">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String toBinary(String str)</span><span id="Codehighlighter1_88_277_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_88_277_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">char</span><span style="color: #000000">[] strChar </span><span style="color: #000000">=</span><span style="color: #000000"> str.toCharArray();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        String result </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">""</span><span style="color: #000000">;<br /> <img id="Codehighlighter1_191_254_Open_Image" onclick="this.style.display='none'; Codehighlighter1_191_254_Open_Text.style.display='none'; Codehighlighter1_191_254_Closed_Image.style.display='inline'; Codehighlighter1_191_254_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_191_254_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_191_254_Closed_Text.style.display='none'; Codehighlighter1_191_254_Open_Image.style.display='inline'; Codehighlighter1_191_254_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">for</span><span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> strChar.length; i</span><span style="color: #000000">++</span><span style="color: #000000">)</span><span id="Codehighlighter1_191_254_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_191_254_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />            <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />            result </span><span style="color: #000000">+=</span><span style="color: #000000"> Integer.toBinaryString(strChar[i]) </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> result;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #008000">//</span><span style="color: #008000">二q制字符串{换成Unicode字符?/span><span style="color: #008000"><br /> <img id="Codehighlighter1_338_550_Open_Image" onclick="this.style.display='none'; Codehighlighter1_338_550_Open_Text.style.display='none'; Codehighlighter1_338_550_Closed_Image.style.display='inline'; Codehighlighter1_338_550_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_338_550_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_338_550_Closed_Text.style.display='none'; Codehighlighter1_338_550_Open_Image.style.display='inline'; Codehighlighter1_338_550_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" /></span><span style="color: #000000">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String toStr(String binStr)</span><span id="Codehighlighter1_338_550_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_338_550_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        String[] tempStr </span><span style="color: #000000">=</span><span style="color: #000000"> StrToStrArray(binStr);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">char</span><span style="color: #000000">[] tempChar </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> </span><span style="color: #0000ff">char</span><span style="color: #000000">[tempStr.length];<br /> <img id="Codehighlighter1_471_512_Open_Image" onclick="this.style.display='none'; Codehighlighter1_471_512_Open_Text.style.display='none'; Codehighlighter1_471_512_Closed_Image.style.display='inline'; Codehighlighter1_471_512_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_471_512_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_471_512_Closed_Text.style.display='none'; Codehighlighter1_471_512_Open_Image.style.display='inline'; Codehighlighter1_471_512_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">for</span><span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> tempStr.length; i</span><span style="color: #000000">++</span><span style="color: #000000">)</span><span id="Codehighlighter1_471_512_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_471_512_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />            tempChar[i] </span><span style="color: #000000">=</span><span style="color: #000000"> toChar(tempStr[i]);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> String.valueOf(tempChar);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #008000">//</span><span style="color: #008000">二q制字符串{换ؓchar</span><span style="color: #008000"><br /> <img id="Codehighlighter1_605_780_Open_Image" onclick="this.style.display='none'; Codehighlighter1_605_780_Open_Text.style.display='none'; Codehighlighter1_605_780_Closed_Image.style.display='inline'; Codehighlighter1_605_780_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_605_780_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_605_780_Closed_Text.style.display='none'; Codehighlighter1_605_780_Open_Image.style.display='inline'; Codehighlighter1_605_780_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" /></span><span style="color: #000000">    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">char</span><span style="color: #000000"> toChar(String binStr)</span><span id="Codehighlighter1_605_780_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_605_780_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">int</span><span style="color: #000000">[] temp </span><span style="color: #000000">=</span><span style="color: #000000"> binStrToIntArray(binStr);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">int</span><span style="color: #000000"> sum </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> <img id="Codehighlighter1_704_752_Open_Image" onclick="this.style.display='none'; Codehighlighter1_704_752_Open_Text.style.display='none'; Codehighlighter1_704_752_Closed_Image.style.display='inline'; Codehighlighter1_704_752_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_704_752_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_704_752_Closed_Text.style.display='none'; Codehighlighter1_704_752_Open_Image.style.display='inline'; Codehighlighter1_704_752_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">for</span><span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> temp.length; i</span><span style="color: #000000">++</span><span style="color: #000000">)</span><span id="Codehighlighter1_704_752_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_704_752_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />            sum </span><span style="color: #000000">+=</span><span style="color: #000000"> temp[temp.length </span><span style="color: #000000">-</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"> </span><span style="color: #000000">-</span><span style="color: #000000"> i] </span><span style="color: #000000"><<</span><span style="color: #000000"> i;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> (</span><span style="color: #0000ff">char</span><span style="color: #000000">)sum;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #008000">//</span><span style="color: #008000">初始二q制字符串{换成字符串数l,以空格相?/span><span style="color: #008000"><br /> <img id="Codehighlighter1_852_880_Open_Image" onclick="this.style.display='none'; Codehighlighter1_852_880_Open_Text.style.display='none'; Codehighlighter1_852_880_Closed_Image.style.display='inline'; Codehighlighter1_852_880_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_852_880_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_852_880_Closed_Text.style.display='none'; Codehighlighter1_852_880_Open_Image.style.display='inline'; Codehighlighter1_852_880_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" /></span><span style="color: #000000">    </span><span style="color: #0000ff">private</span><span style="color: #000000"> String[] StrToStrArray(String str)</span><span id="Codehighlighter1_852_880_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_852_880_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> str.split(</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #008000">//</span><span style="color: #008000">二q制字符串{换成int数组</span><span style="color: #008000"><br /> <img id="Codehighlighter1_950_1128_Open_Image" onclick="this.style.display='none'; Codehighlighter1_950_1128_Open_Text.style.display='none'; Codehighlighter1_950_1128_Closed_Image.style.display='inline'; Codehighlighter1_950_1128_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_950_1128_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_950_1128_Closed_Text.style.display='none'; Codehighlighter1_950_1128_Open_Image.style.display='inline'; Codehighlighter1_950_1128_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" /></span><span style="color: #000000">    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000">[] binStrToIntArray(String binStr)</span><span id="Codehighlighter1_950_1128_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_950_1128_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">char</span><span style="color: #000000">[] temp </span><span style="color: #000000">=</span><span style="color: #000000"> binStr.toCharArray();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">int</span><span style="color: #000000">[] result </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000">[temp.length];<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    <br /> <img id="Codehighlighter1_1072_1105_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1072_1105_Open_Text.style.display='none'; Codehighlighter1_1072_1105_Closed_Image.style.display='inline'; Codehighlighter1_1072_1105_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1072_1105_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1072_1105_Closed_Text.style.display='none'; Codehighlighter1_1072_1105_Open_Image.style.display='inline'; Codehighlighter1_1072_1105_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">for</span><span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> temp.length; i</span><span style="color: #000000">++</span><span style="color: #000000">)</span><span id="Codehighlighter1_1072_1105_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1072_1105_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />            result[i] </span><span style="color: #000000">=</span><span style="color: #000000"> temp[i] </span><span style="color: #000000">-</span><span style="color: #000000"> </span><span style="color: #000000">48</span><span style="color: #000000">;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> result;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    <br /> <img id="Codehighlighter1_1171_2189_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1171_2189_Open_Text.style.display='none'; Codehighlighter1_1171_2189_Closed_Image.style.display='inline'; Codehighlighter1_1171_2189_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1171_2189_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1171_2189_Closed_Text.style.display='none'; Codehighlighter1_1171_2189_Open_Image.style.display='inline'; Codehighlighter1_1171_2189_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> main(String[] args)</span><span id="Codehighlighter1_1171_2189_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1171_2189_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        StrBinaryTurn cTob </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StrBinaryTurn();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println(cTob.toBinary(</span><span style="color: #000000">"</span><span style="color: #000000">子Q好吃!aaa</span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println(cTob.toBinary(</span><span style="color: #000000">"</span><span style="color: #000000">999111</span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println(cTob.toBinary(</span><span style="color: #000000">"</span><span style="color: #000000">What a nice day!</span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println(cTob.toBinary(</span><span style="color: #000000">"</span><span style="color: #000000">^@^ - -! Q)?/span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println(cTob.toStr(</span><span style="color: #000000">"</span><span style="color: #000000">110101001011000 101101101010000 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">1111111100001100 101100101111101 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">101010000000011 1111111100000001 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">1100001 1100001 1100001 </span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println(cTob.toStr(</span><span style="color: #000000">"</span><span style="color: #000000">111001 111001 111001 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">110001 110001 110001</span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println(cTob.toStr(</span><span style="color: #000000">"</span><span style="color: #000000">1010111 1101000 1100001 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">1110100 100000 1100001 100000 1101110 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">1101001 1100011 1100101 100000 1100100 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">1100001 1111001 100001 </span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.println(cTob.toStr(</span><span style="color: #000000">"</span><span style="color: #000000">1011110 1000000 1011110 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">100000 101101 100000 101101 100001 100000 </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">"</span><span style="color: #000000">1111111100001000 1111111100001001 10011000000101 </span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span></div> <br /> 输出l果:<br /> <p>110101001011000 101101101010000 1111111100001100 101100101111101 101010000000011 1111111100000001 1100001 1100001 1100001 </p> <p>111001 111001 111001 110001 110001 110001 </p> <p>1010111 1101000 1100001 1110100 100000 1100001 100000 1101110 1101001 1100011 1100101 100000 1100100 1100001 1111001 100001 </p> <p>1011110 1000000 1011110 100000 101101 100000 101101 100001 100000 1111111100001000 1111111100001001 10011000000101 </p> <p><br /> 子Q好吃!aaa<br /> 999111<br /> What a nice day!<br /> ^@^ - -! Q)?/p> <br /> <br /> <img src ="http://www.aygfsteel.com/orangehf/aggbug/153810.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/orangehf/" target="_blank">南</a> 2007-10-18 11:42 <a href="http://www.aygfsteel.com/orangehf/archive/2007/10/18/153810.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>my俄罗斯方块修正BUG和新功能!提供下蝲!http://www.aygfsteel.com/orangehf/archive/2007/10/13/152576.htmlSat, 13 Oct 2007 07:25:00 GMThttp://www.aygfsteel.com/orangehf/archive/2007/10/13/152576.htmlhttp://www.aygfsteel.com/orangehf/comments/152576.htmlhttp://www.aygfsteel.com/orangehf/archive/2007/10/13/152576.html#Feedback18http://www.aygfsteel.com/orangehf/comments/commentRss/152576.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/152576.html
1.方块cBlock的clear和drawҎ׃两个U程(一个是ȝE?一个是定时器线E?都要调用,而且之前我没做好U程的同?所以会随机发生该擦除的方块没能及时擦除,或是两个方块重?

修正Ҏ:
ȝE是在方块的左移,右移,下移,变Ş,直降 ?moveLeft(),moveRight(),moveDown(),rotateClock(),fall() q些Ҏ中调用Block的clear和drawҎ?定时器线E是在线E活动时调用moveDown(),所?moveDown()成了界区,不能保证被调用的序,所以需要他们同步,要他们同步,只需他们都写到一个方法里,?move(moveSuit type),q且moveҎ同步,卛_关键字synchronized卛_.

2.q是U程没有同步造成的问?在定时器U程zd时会判断方块是否能下?如果能就下落,在主U程???或空g会执行前句所说的d,但由于是两个U程各自判断方块是否能下?所以判断是否能下落的方法和下移Ҏ的调用顺序不能被保证,所以有时会发生q样的情?按住?方块有时会下落到出面板一?或是几个方块重合,即主U程判断方块不能下落,但定时器U程在主U程判断方块不能下落之前,判断方块可以下落,于是方块多下落了一?q个序?定时U程判断可以下落 -> ȝE判断不能下?-> ȝE不?-> 定时U程让方块下?-> 造成异常发生或方块重合现?

修正Ҏ:
?nbsp;move(moveSuit type)Ҏ的MOVEDOWN情况?再一ơ判断方块是否能下落,move(moveSuit type)Ҏ是同步的,所以可以很好的解决q个问题.

1,2修正后代码如?
public enum MoveSuit {
        MOVELEFT,
        MOVERIGHT,
        MOVEDOWN,
        ROTATE,
        FALL
    }


    
//UdҎ,通过Udcd军_如何Ud
    public synchronized void move(MoveSuit type, TetrisBoard tetrisBoard){
        
        
switch(type){
        
        
case MOVELEFT:
            moveLeft();
            
break;
        
case MOVERIGHT:
            moveRight();
            
break;
        
case MOVEDOWN:
            
if(tetrisBoard.canMoveDown(this))
                moveDown();
            
break;
        
case ROTATE:
            clear();
            rotateClock().draw();
            
break;
        
case FALL:
            fall(tetrisBoard);
            
break;
            
        }

    }


3.如果GameOver一ơ以后再TryAgain,游戏{和方块下落间隔会在分数到?00分左xH然变到刚才GameOver时的最高等U和方块下落间隔.

修正Ҏ:
游戏{和方块下落间隔都是通过消行L判断?之前我忘记再每次游戏开始时消行L设ؓ0,所以只需要在TetrisBoardcM加一个setRemovedLinesҎ,在GamecM的startGameҎ中调用setRemovedLines(0)卛_.

4.每个方块的Ҏ原来我设Z白色,在两个大方块怏时会其中一个大方块的一部分Ҏ擦除,比较隄,如果把小方块长宽~小一个象?当两个大方块怏?衔接处就会有两个Ҏ,也不是很好看.

修正Ҏ:边框颜色设景色黑色,q样Ҏ被擦除也看不出来,两个大方块衔接处只有一个边?可以两全其美.虽然q个Ҏ不太?..


BUG说完?该说?span style="color: #ff6600">新功?/span>?呵呵~

我又d了一个可以记录ƈ昄最好成l信息的功能,玩游戏d有个奔头?嘿嘿!
W一ơ玩游戏?最高分?,最高等Uؓ1,创造者姓名ؓ"Are you the winner?"
当游戏gameover?如果当前游戏分数大于最高分,p玩家输入自己姓名,q将其和最高分?{加密后存入myTetris.dat.
重新打开游戏?会从myTetris.dat中读取信息ƈ解密,q将最高分,最高等U和最高分创造者显C在游戏界面?br />
最后添张图:


最后把jar包和源代码放出来!希望大家l我留言,互相交流,嘿嘿!
以前忘说?如果惌帮助正常昄的话,需要在和jar包同U目录下新徏个文件夹叫pics,然后在里面放一个叫logo的图?
myTetris下蝲地址
谢谢大家Ҏ的支?


 



2007-10-13 15:25 发表评论
]]>
TEA加密法java?/title><link>http://www.aygfsteel.com/orangehf/archive/2007/10/12/152328.html</link><dc:creator>南</dc:creator><author>南</author><pubDate>Fri, 12 Oct 2007 06:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/orangehf/archive/2007/10/12/152328.html</guid><wfw:comment>http://www.aygfsteel.com/orangehf/comments/152328.html</wfw:comment><comments>http://www.aygfsteel.com/orangehf/archive/2007/10/12/152328.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.aygfsteel.com/orangehf/comments/commentRss/152328.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/orangehf/services/trackbacks/152328.html</trackback:ping><description><![CDATA[     摘要:          最q在修改我的俄罗斯方块的同时,又添加了一个显Cƈ记录最好成l的功能,需要将信息加密/解密,存入文g/d文g,在我下铺(牛h?)的指点下,采用了TEA加密法.            ...  <a href='http://www.aygfsteel.com/orangehf/archive/2007/10/12/152328.html'>阅读全文</a><img src ="http://www.aygfsteel.com/orangehf/aggbug/152328.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/orangehf/" target="_blank">南</a> 2007-10-12 14:04 <a href="http://www.aygfsteel.com/orangehf/archive/2007/10/12/152328.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>要求_{案避免用double和floathttp://www.aygfsteel.com/orangehf/archive/2007/10/05/150490.htmlFri, 05 Oct 2007 02:36:00 GMThttp://www.aygfsteel.com/orangehf/archive/2007/10/05/150490.htmlhttp://www.aygfsteel.com/orangehf/comments/150490.htmlhttp://www.aygfsteel.com/orangehf/archive/2007/10/05/150490.html#Feedback5http://www.aygfsteel.com/orangehf/comments/commentRss/150490.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/150490.html q可真让我大吃一?!我很不解,而且不是很相?于是我写了两个个E序试验了下.

 1public class TestFloatDouble {
 2
 3    public static void main(String[] args) {
 4
 5        float a = (float1.03;
 6        float b = (float) .42;
 7        
 8        double c = 1.03;
 9        double d = .42;
10        
11        System.out.println(a * b);
12        System.out.println(c - d);
13    }

14
15}

输出l果?br /> 0.43259996
0.6100000000000001

而正结果应?br /> 0.4326
0.61


如果需要得到精答?那就用java.math里的BigDecimal?虽然效率相对低一?但至是正确?!!
 1import java.math.BigDecimal;
 2
 3public class TestBigDecimal {
 4
 5    public static void main(String[] args) {
 6
 7        BigDecimal a = new BigDecimal("1.03");
 8        BigDecimal b = new BigDecimal(".42");
 9        
10        System.out.println(a.multiply(b));
11        System.out.println(a.subtract(b));
12        
13    }

14
15}

输出l果同样也是正确l果?br /> 0.4326
0.61

我就不会?谁能告诉我这是ؓ什么呢???????
各位大虾们给偶指点下!!!

2007-10-05 10:36 发表评论
]]>
my俄罗斯方?http://www.aygfsteel.com/orangehf/archive/2007/10/01/150025.htmlMon, 01 Oct 2007 02:42:00 GMThttp://www.aygfsteel.com/orangehf/archive/2007/10/01/150025.htmlhttp://www.aygfsteel.com/orangehf/comments/150025.htmlhttp://www.aygfsteel.com/orangehf/archive/2007/10/01/150025.html#Feedback45http://www.aygfsteel.com/orangehf/comments/commentRss/150025.htmlhttp://www.aygfsteel.com/orangehf/services/trackbacks/150025.html 俺就~了一?
       ׃本h水^有限(偶只是个刚大四的学生),法或是实现不会很精?~的时候也没特别考虑效率,不过本h觉着q凑合吧 嘿嘿!~
       如果有谁惌学习SWT~程或是想了解下俄罗斯方块该怎么?那就留下你的邮箱?我会把源代码发给?每天我至会看一ơ博的噢.. -0-
       如果我的代码或想法有什么缺?请大家指出哈!

       攑և个截?
1-----------------------


2-------------------------


3------------------------------


4---------------------------------


5----------------------------

6----------------------------

2007-10-01 10:42 发表评论
]]>
վ֩ģ壺 | | | ƽ| | ׯ| ˳ƽ| Ӫ| | Դ| ɽ| ˮ| ˳| | | | Ͳ| ˻| ˮ| ˹| | | | | ٲ| ʱ| ף| ̩| פ| | Թ| ʲ| | | | ͨɽ| | | ʡ| | |