JSP page Subtraction

Source: Internet
Author: User

Multiplication
function Nummulti (NUM1, num2) {
var basenum = 0;
try {
Basenum + = Num1.tostring (). Split (".") [1].length;
} catch (e) {
}
try{
Basenum + = Num2.tostring (). Split (".") [1].length;
} catch (e) {
}
Return number (num1.tostring (). Replace (".", "")) * Number (num2.tostring (). Replace (".", "") "/Math.pow (Basenum);
}
Addition
function Numadd (NUM1, num2) {
var basenum, BaseNum1, baseNum2;
try {
BASENUM1 = Num1.tostring (). Split (".") [1].length;
} catch (e) {
BASENUM1 = 0;
}
try {
baseNum2 = Num2.tostring (). Split (".") [1].length;
} catch (e) {
baseNum2 = 0;
}
Basenum = Math.pow (Ten, Math.max (basenum1,basenum2));
Return (Nummulti (num1,basenum) +nummulti (num2,basenum))/basenum;
}
Subtraction
function Numsubtr (num1,num2) {
var basenum, BaseNum1, baseNum2;
try{
Basenum1=num1.tostring (). Split (".") [1].length;
}catch (e) {
basenum1=0;
}
try{
Basenum2=num2.tostring (). Split (".") [1].length;
}catch (e) {
basenum2=0;
}
Basenum=math.pow (10,math.max (basenum1,basenum2));
Return (Nummulti (num1,basenum)-nummulti (num2,basenum))/basenum;
}
Division
function Numdiv (num1,num2) {
var basenum, BaseNum1, baseNum2;
try{
Basenum1=num1.tostring (). Split (".") [1].length;
}catch (e) {
basenum1=0;
}
try{
Basenum2=num2.tostring (). Split (".") [1].length;
}catch (e) {
basenum2=0;
}
With (Math) {
Basenum=math.pow (10,BASENUM2-BASENUM1);
Return (number (num1.tostring (). Replace (".", ""))/number (Num2.tostring (). Replace (".", ""))) *basenum;
}
}
Calculates the two date difference between days
function DateDiff (sDate1, SDate2) {//sdate1 and sDate2 are in YYYY-MM-DD format
var adate, oDate1, ODate2, idays;
Adate = Sdate1.split ("") [0].split ("-");
oDate1 = new Date (adate[0] + '-' + adate[1] + '-' + adate[2]); Convert to YYYY-MM-DD format
Adate = Sdate2.split ("-");
ODate2 = new Date (adate[0] + '-' + adate[1] + '-' + adate[2]);
Idays = parseint ((odate1-odate2)/1000/60/60/24); Converts the difference in milliseconds to days
return idays; Returns the difference in days
}

JSP page Subtraction

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.