Crimson Editor

Built-in Calculator

Crimson Editor is equiped with a calculator that can evaluate simple expressions. If you want to calculate a simple expression, use Crimson Editor built-in calculator to get the answer quickly.

Following examples show how to use Crimson Editor built-in calculator.

  1. Type in the expression you want to evaluate in Crimson Editor. (The whole expression should be written in one line)
  2. Press Ctrl+Enter to calculate the expression when the caret is in the line of expression.

i.e.

3.14 * (2.43 + 0.91)   <- press Ctrl+Enter when the caret is in the line of expression
= 10.487600            <- you will get the answer immediately

If you want to use the value that was evaluated in the earler step, use a special variable named $ans. There is another built-in variable named $pi, and the value of the variable $pi is 3.1415926535.

$ans / $pi
= 3.338307

Crimson Editor supports basic mathmatics functions which are very similar to those used in C math library.

sin(1.2) + atan2(3.2, 4.3)
= 1.571809

Following list shows basic mathmatics functions supported by Crimson Editor.

abs, fabs, mod, fmod, ceil, floor, round, min, max, acos, asin, atan, atan2, cos, sin, tan, cosh, sinh, tanh, exp, log, log10, pow, sqr, sqrt

Date functions, those are frequently used in financial problems, are now available in Crimson Editor 3.45. Following list shows date functions supported by Crimson Editor.

today, yeardays, monthdays, date2days, days2date, eomday, eomdate, weekday, isbizdate, nbizdate, pbizdate, adddays, addmonths, addterms, days360, days365, daysact, daysbet, monthsbet, termsbet, termfrac, yearfrac

Mathmatics Functions

FunctionDescription
abs, fabsabsolute value functions. fabs(x) returns the absolute value of x, |x|.
mod, fmodremainder functions. fmod(x, y) returns the remainder f of the division of x by y, where f has the same sign as x, such that x=iy+f for some integer i, and |f| < |y|.
ceilceiling function. ceil(x) returns the smallest integer not less than x.
floorfloor function. floor(x) returns the largest integer not greater than x.
roundround function. round(x) rounds its argument to the nearest integral value.
minmin(x, y) returns the minimum of a pair of values.
maxmax(x, y) returns the maximum of a pair of values.
acosarccosine function. acos(x) returns the arccosine of x in the range 0 to pi.
asinarcsine function. asin(x) returns the arcsine of x in the range -pi/2 to pi/2.
atanarctangent function. atan(x) returns the arctangent of x in the range -pi/2 to pi/2.
atan2arctangent-and-quadrant function. atan2(y, x) returns the arctangent of y/x, in the range -pi to pi, using the signs of both arguments to determine the quadrant of the return value.
coscosine function. cos(x) returns the cosine of x (x specified in radians).
sinsine function. sin(x) returns the sine of x (x specified in radians).
tantangent function. tan(x) returns the tangent of x (x specified in radians).
coshhyperbolic cosine function. cosh(x) returns the hyperbolic cosine of its argument.
sinhhyperbolic sine function. sinh(x) returns the hyperbolic sine of its argument.
tanhhyperbolic tangent function. tanh(x) returns the hyperbolic tangent of its argument.
expexponential function. exp(x) returns e^x.
lognatural logarithm function. log(x) returns the natural logarithm of x. The value of x must be greater than zero.
log10common logarithm function. log10(x) returns the logarithm base ten of x. The value of x must be greater than zero.
powpower function. pow(x, y) returns x^y. If x is negative, y must be an integer value.
sqrsquare function. sqr(x) returns x*x.
sqrtsquare root function. sqrt(x) returns the non-negative square root of x. The value of x must not be less than zero.

Date Functions

FunctionDescription
todaycurrent date. today() returns the current date as a number. i.g. 20020807 (Aug. 07, 2002)
yeardaysnumber of days in a year. yeardays(year) returns the actual number of days in the given year.
monthdaysnumber of days in a month. monthdays(year, month) returns the actual number of days in the given month.
date2daysdate to serial date number conversion. date2days(date) returns the number of days to the given date since the Epoch.
days2dateserial date number to date conversion. days2date(days) returns the date calculated from the given number of days since the Epoch.
eomdaylast day of month. eomday(year, month) returns the last day of the month for the given year and month.
eomdatelast date of month. eomdate(year, month) returns the last date of the month for the given year and month.
weekdayday of the week. weekday(date) returns the day of the week in numeric form. weekday: 0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat
isbizdatetrue for date that is business day. isbizday(date) returns 1 if date is a business day and 0 otherwise.
nbizdatenext business day. nbizdate(date) returns the date of the next business day from the reference date.
pbizdateprevious business day. pbizdate(date) returns the date of the previous business day from the reference date.
adddaysdate added by given days. adddays(date, days) returns the reference date added by given days.
addmonthsdate added by given months. addmonths(date, months, end_month) returns the reference date added by given months. end_month: 0 = actual, 1 = end month
addtermsdate added by given terms. addterms(date, terms, frequency, end_month) returns the reference date added by given terms. frequency: 1 = annual, 2 = semiannual, 4 = quarterly, 6 = bimonthly, 12 = monthly; end_month: 0 = actual, 1 = end month
days360days between dates based on 360-day year. days360(start_date, end_date, european) returns the number of days between start_date and end_date based on a 360-day year. european: 0 = american, 1 = european
days365days between dates based on 365-day year. days365(start_date, end_date) returns the number of days between start_date and end_date based on a 365-day year.
daysactactual number of days between dates. daysact(start_date, end_date) returns the actual number of days between two dates.
daysbetdays between dates for any day-count basis. daysbet(start_date, end_date, basis) returns the number of days between start_date and end_date using the given day-count basis. basis: 0 = actual/actual, 1 = actual/360, 2 = actual/365, 3 = 30/360, 4 = 30E/360, 5 = NL/365
monthsbetmonths between dates. monthsbet(start_date, end_date) returns the number of months between start_date and end_date.
termsbetterms between dates. termsbet(start_date, end_date, frequency) returns the number of terms between start_date and end_date. frequency: 1 = annual, 2 = semiannual, 4 = quarterly, 6 = bimonthly, 12 = monthly
termfracfraction of term between dates. termfrac(start_date, end_date, frequency, basis, end_month) returns a fraction based on the number of days between start_date and end_date using the given day-count basis. frequency: 1 = annual, 2 = semiannual, 4 = quarterly, 6 = bimonthly, 12 = monthly; basis: 0 = actual/actual, 1 = actual/360, 2 = actual/365, 3 = 30/360, 4 = 30E/360, 5 = NL/365; end_month: 0 = actual, 1 = end month
yearfracfraction of year between dates. yearfrac(start_date, end_date, basis, end_month) returns a fraction based on the number of days between start_date and end_date using the given day-count basis. basis: 0 = actual/actual, 1 = actual/360, 2 = actual/365, 3 = 30/360, 4 = 30E/360, 5 = NL/365; end_month: 0 = actual, 1 = end month