Typically, a float or double is used to calculate the currency.What does the following calculation output?System.out.println (2.00-1.10);Started thinking it would be 0.90, the actual result is: 0.8999999999999999The reason is that not all decimals can be accurately represented by binary floating point.How to transform it?
Use int, long to calculate, and then convert to floating point number.
Use BigDecimal to calculate.
System.out.println (New BigDecimal ("2.00"). Subtract (New BigDec
It's easy to write down the following code to judge parity:public static Boolean isodd (int num) { return num% 2 = = 1;}The idea follows the odd-numbered standard of mathematical judgment: "2 is equal to 1".Is this code valid for negative numbers?System.out.println (IsOdd (-3));-3 is odd and should return true.The actual result:Java paritytest falseJava does not convert a negative result to a positive integer when it processes the take-out operation.Perform:System.out.println ("-3% 2 =" + (-3
system routines.User-level line threads has two obvious drawbacks for kernel-level threading:1> in a typical operating system, many system calls can cause blocking. Therefore, when a user-level thread executes a system call, not only will the thread be blocked, but all threads in the process will be blocked.2> in a purely user-level threading strategy, a multithreaded application cannot take advantage of multi-processing techniques.You can solve these two problems by writing the application as
given file.Syntax: Whereis filenameFor example, use the Whereis ls command to find the full path to the LS file's executable file, source code, and man file. iv. Find CommandThe Find command is the most powerful file finder in a Linux system, and the Find command finds files based on a user-specified starting lookup path and uses regular expressions for fuzzy matching.Syntax: Find path expressionPath: The user-specified start lookup path.Expression: Regular expression.For example, use the Find
] ~]# tar--EXCLUDE/HOME/DMTSAI-ZCVF myfile.tar.gz/home/*/etc
In addition: the C parameter of the TAR command
$ TAR-CVF File2.tar/home/usr2/file2Tar:removing leading '/' from the Members namesHome/usr2/file2This command can package the/home/usr2/file2 file into the File2.tar in the current directory, note that the source file identified with the absolute path, after compression with the tar command, with the absolute path (here is the home/usr2/, root directory '/' is automatically removed
Clause 21: When you must return an object, don't be paranoid about returning it referenceExample:The Raional class can perform some operations on the rational number and use the heap memory request and its operator* function asConst rational operator* (const rational lhs,const rational RHS) {ratinal* result = new Rational (...); return * result;The heap memory request was made in the function, so there is no problem returning the reference, but the problem is the followingRational w,x,y,z;w=x*y*
Write a program today, an exception occurredJava.lang.NoClassDefFoundErrorThen the error message isA class file is not written. The project is inconsistent, if so try refreshing this project and building itInternet search, there is said I workspace full, but not ah, my computer although slag, this memory may still have AH. The final answer is funny:Here are some other reserved words that cannot be created under Windows. Pay attention, don't divide the case. Con,con,con can not!Con is a device na
obtain in a database.Setteings.py is made up of a large number of scrapy settings, such as whether robot protocol is followed.ConclusionAt this point we have implemented the installation of scrapy and the implementation of the basic framework, but has not carried out specific programming, the next I will take everyone to achieve the first Jobbole "the latest article" of all the article crawl, to initially experience the fun of Scrapy crawler. Then gradually into the simulation landing, breaking
1. ReferencesA reference is the meaning of an alias.The reference must be initialized and must be of the same type, the address of the reference variable and the address of the source variable must be on the same memory address, where the reference variable and the source variable have any numeric changes that affect each otherThe reference variable does the argument,void Step (int a,int b){int C = b;b = A;A = C;}Main ...{int ri = i;int rj=j;Step (I,J);}2. Input and OUTPUT functionsWhen entering
1. Change the first letter of the string to uppercase ' Welcome to Bokeyuan ' = s.capitalize ()print ()2. Turn string all to case' Welcome to Bokeyuan ' = = = S.lower () print (S2) print (S3)3. Center The character, you can add a fill to replaces = ' Menu ' s4 = S.center (S5) = S.center (+, '-') print (S4) print (S5)>>>Menu--------Menu--------4. View the length of the strings = ' I like reading, Thank ' s6 = Len (s) print (S6) >>> #标点也算一位5. Specify the separator to split the
particular value is already included in the list, use the keyword in.>>>items = ['a','b','c' ]>>>'a' in items True>>> ' D ' inch ItemsfalseCheck if a specific value is not included in the listYou can use not in.Banned_users = ['a','b','C']user='D'ifUser not inchbanned_users:Print(User +'Not in the list')4.2 If statementA simple if statement has only one test and one operationAge = Allif age >=: print("enough to vote! ")In the IF statement, the indentation is the same as in the For loop.If-
Use map, area, coords to add events to different areas of the picture5 seconds after the pop-up box is displayed for 5 secondsUse settimeout to achieve a countdown effectJavaScript Learning Essay 2
Clustering (cluster)Partitioning Methods:K-meansSaquential LeaderModel Based MethodsDensity Based MethodsHierachical MethodsUnsupervised learning (unsupervised learning)No LabelsData drivenSpecial needs to be aware of:Arbitrary shape handles a wide variety of shapes noise and outlier noise, and the ability to process outliers---------------------------------------------------------------------K-means algorithmEvaluationThis note is mainly about the effect of spherical data is better, for other e
promptRefer to the files in the current directory, you can use the single point operator in the shell.(./file referencing the current directory ********)Ls-l test1The next step is to give yourself permission to execute the file, using the chmod commandchmod u+x Test1Success... Now that you have all the conditions, you can execute this new shell script file.You can insert echo anywhere in a text fileFor example:#! Bin/bash (Tell the Shell to run the following script)#this is a script displaysech
1.PS-EF:-e Displays all processes running on the system,-f displays some useful information columnsUID: The user responsible for initiating the processPID: ID of the processPPID: PID of the parent process (a process started by another process)C: Processor utilization for the duration of the processStime: System time at process startupTTY: The terminal device from which the process startsTime: The cumulative CPU times required to run the process;CMD: Name of the startup program2. Search data:grep
name, the percent can also be in front, find the name behind the "pull"Update student12 set age=16 where code=7 --Change CodeDelete from student12 where code=5 --delete Code5 this lineDelete from student12 where code between and --delete rows 10th through 13th datadrop table student12--Deleting tables student12Drop database Yuelie--delete the databases YuelieCREATE DATABASE Yuelie--Creating databasesDelete from student12 where code=6 and---Delete the first few linesSelect top 3*from student12 w
input stdin stdout | is the logo of the piping pipe.Cat -n means plus line number ls | Cat-ncat: 1. Displays the entire file at once. $ cat filename 2. Create a file from the keyboard. $ cat > FileName can only create new files and cannot edit existing files. 3. Merge several files into one file: $cat file1 file2 > fileCat also has the role of creating files14.| Save the value on the variable, use $ () to assign the value to the TT tt=$ (ls | cat-n)15. Write function in one line: repeat () {whi
\b Back\c suppresses (does not display) the newline character at any end of the output (only valid in the parameter string under the%B format designator control), and any characters left in the argument, any subsequent arguments, and any characters left in the format string are ignored\f Page Change (formfeed\ nthe line break\ r Enter (carriage return)\ t Horizontal tab\v Vertical Tab\ \ A literal backslash character\DDD represents a 1 to 3-digit octal value character that is valid only in a for
preceding this line-c#: Displays matching rows and rows before and after this lineGrep-a 2 ' ^core ID '/proc/cpuinfoTo extend the regular expression:Character Matching:. [] [^] Same as basic expressionNumber of matches:* ?+: Match its first character at least once{M,n}Location anchoring:^ $ \Group:(): Group\1,\2,\3 ...Or|:orsuch as: C|cat: Is it cat or cat or C or cat?Grep-e ' c| Cat ' Test6.txtGerp--color-e ' C|cat ' test6.txtgrep--color-e ' (c|c) at ' Test6.txtgrep--color-e ' ^[[:space:]]+ '/
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.