A Long class for representing a 64 bit two\textquotesingle{}s-\/complement integer value derived from the \href{https://github.com/google/closure-library}{\texttt{ Closure Library}} for stand-\/alone use and extended with unsigned support.

\href{https://www.npmjs.com/package/long}{\texttt{ }} \href{https://travis-ci.org/dcodeIO/long.js}{\texttt{ }}\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2311}{}\doxysection{Background}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2311}
As of \href{http://ecma262-5.com/ELS5_HTML.htm\#Section_8.5}{\texttt{ ECMA-\/262 5th Edition}}, \char`\"{}all the positive and negative integers whose magnitude is no greater than 2$<$sup$>$53$<$/sup$>$ are representable in the Number type\char`\"{}, which is \char`\"{}representing the doubleprecision 64-\/bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-\/\+Point Arithmetic\char`\"{}. The \href{https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER}{\texttt{ maximum safe integer}} in Java\+Script is 2\textsuperscript{53}-\/1.

Example\+: 2\textsuperscript{64}-\/1 is 1844674407370955$\ast$$\ast$1615$\ast$$\ast$ but in Java\+Script it evaluates to 1844674407370955$\ast$$\ast$2000$\ast$$\ast$.

Furthermore, bitwise operators in Java\+Script "{}deal only with integers in the range −2\textsuperscript{31} through 2\textsuperscript{31}−1, inclusive, or in the range 0 through 2\textsuperscript{32}−1, inclusive. These operators accept any value of the Number type but first convert each such value to one of 2\textsuperscript{32} integer values."{}

In some use cases, however, it is required to be able to reliably work with and perform bitwise operations on the full 64 bits. This is where long.\+js comes into play.\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2312}{}\doxysection{Usage}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2312}
The class is compatible with Common\+JS and AMD loaders and is exposed globally as {\ttfamily Long} if neither is available.


\begin{DoxyCode}{0}
\DoxyCodeLine{var Long = require("{}long"{});}
\DoxyCodeLine{}
\DoxyCodeLine{var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(longVal.toString());}
\DoxyCodeLine{... }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2313}{}\doxysection{API}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2313}
\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2314}{}\doxysubsection{Constructor}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2314}

\begin{DoxyItemize}
\item new {\bfseries{Long}}(low\+: {\ttfamily number}, high\+: {\ttfamily number}, unsigned?\+: {\ttfamily boolean})~\newline
 Constructs a 64 bit two\textquotesingle{}s-\/complement integer, given its low and high 32 bit values as {\itshape signed} integers. See the from$\ast$ functions below for more convenient ways of constructing Longs.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2315}{}\doxysubsection{Fields}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2315}

\begin{DoxyItemize}
\item Long\#$\ast$$\ast$low$\ast$$\ast$\+: {\ttfamily number}~\newline
 The low 32 bits as a signed value.
\item Long\#$\ast$$\ast$high$\ast$$\ast$\+: {\ttfamily number}~\newline
 The high 32 bits as a signed value.
\item Long\#$\ast$$\ast$unsigned$\ast$$\ast$\+: {\ttfamily boolean}~\newline
 Whether unsigned or not.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2316}{}\doxysubsection{Constants}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2316}

\begin{DoxyItemize}
\item Long.$\ast$$\ast$\+ZERO$\ast$$\ast$\+: {\ttfamily Long}~\newline
 Signed zero.
\item Long.$\ast$$\ast$\+ONE$\ast$$\ast$\+: {\ttfamily Long}~\newline
 Signed one.
\item Long.$\ast$$\ast$\+NEG\+\_\+\+ONE$\ast$$\ast$\+: {\ttfamily Long}~\newline
 Signed negative one.
\item Long.$\ast$$\ast$\+UZERO$\ast$$\ast$\+: {\ttfamily Long}~\newline
 Unsigned zero.
\item Long.$\ast$$\ast$\+UONE$\ast$$\ast$\+: {\ttfamily Long}~\newline
 Unsigned one.
\item Long.$\ast$$\ast$\+MAX\+\_\+\+VALUE$\ast$$\ast$\+: {\ttfamily Long}~\newline
 Maximum signed value.
\item Long.$\ast$$\ast$\+MIN\+\_\+\+VALUE$\ast$$\ast$\+: {\ttfamily Long}~\newline
 Minimum signed value.
\item Long.$\ast$$\ast$\+MAX\+\_\+\+UNSIGNED\+\_\+\+VALUE$\ast$$\ast$\+: {\ttfamily Long}~\newline
 Maximum unsigned value.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2317}{}\doxysubsection{Utility}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2317}

\begin{DoxyItemize}
\item Long.$\ast$$\ast$is\+Long$\ast$$\ast$(obj\+: {\ttfamily $\ast$})\+: {\ttfamily boolean}~\newline
 Tests if the specified object is a Long.
\item Long.$\ast$$\ast$from\+Bits$\ast$$\ast$(low\+Bits\+: {\ttfamily number}, high\+Bits\+: {\ttfamily number}, unsigned?\+: {\ttfamily boolean})\+: {\ttfamily Long}~\newline
 Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits.
\item Long.$\ast$$\ast$from\+Bytes$\ast$$\ast$(bytes\+: {\ttfamily number\mbox{[}\mbox{]}}, unsigned?\+: {\ttfamily boolean}, le?\+: {\ttfamily boolean})\+: {\ttfamily Long}~\newline
 Creates a Long from its byte representation.
\item Long.$\ast$$\ast$from\+Bytes\+LE$\ast$$\ast$(bytes\+: {\ttfamily number\mbox{[}\mbox{]}}, unsigned?\+: {\ttfamily boolean})\+: {\ttfamily Long}~\newline
 Creates a Long from its little endian byte representation.
\item Long.$\ast$$\ast$from\+Bytes\+BE$\ast$$\ast$(bytes\+: {\ttfamily number\mbox{[}\mbox{]}}, unsigned?\+: {\ttfamily boolean})\+: {\ttfamily Long}~\newline
 Creates a Long from its big endian byte representation.
\item Long.$\ast$$\ast$from\+Int$\ast$$\ast$(value\+: {\ttfamily number}, unsigned?\+: {\ttfamily boolean})\+: {\ttfamily Long}~\newline
 Returns a Long representing the given 32 bit integer value.
\item Long.$\ast$$\ast$from\+Number$\ast$$\ast$(value\+: {\ttfamily number}, unsigned?\+: {\ttfamily boolean})\+: {\ttfamily Long}~\newline
 Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
\item Long.$\ast$$\ast$from\+String$\ast$$\ast$(str\+: {\ttfamily string}, unsigned?\+: {\ttfamily boolean}, radix?\+: {\ttfamily number})~\newline
 Long.$\ast$$\ast$from\+String$\ast$$\ast$(str\+: {\ttfamily string}, radix\+: {\ttfamily number})~\newline
 Returns a Long representation of the given string, written using the specified radix.
\item Long.$\ast$$\ast$from\+Value$\ast$$\ast$(val\+: {\ttfamily $\ast$}, unsigned?\+: {\ttfamily boolean})\+: {\ttfamily Long}~\newline
 Converts the specified value to a Long using the appropriate from$\ast$ function for its type.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2318}{}\doxysubsection{Methods}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2318}

\begin{DoxyItemize}
\item Long\#$\ast$$\ast$add$\ast$$\ast$(addend\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns the sum of this and the specified Long.
\item Long\#$\ast$$\ast$and$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns the bitwise AND of this Long and the specified.
\item Long\#$\ast$$\ast$compare$\ast$$\ast$/$\ast$$\ast$comp$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily number}~\newline
 Compares this Long\textquotesingle{}s value with the specified\textquotesingle{}s. Returns {\ttfamily 0} if they are the same, {\ttfamily 1} if the this is greater and {\ttfamily -\/1} if the given one is greater.
\item Long\#$\ast$$\ast$divide$\ast$$\ast$/$\ast$$\ast$div$\ast$$\ast$(divisor\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns this Long divided by the specified.
\item Long\#$\ast$$\ast$equals$\ast$$\ast$/$\ast$$\ast$eq$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value equals the specified\textquotesingle{}s.
\item Long\#$\ast$$\ast$get\+High\+Bits$\ast$$\ast$()\+: {\ttfamily number}~\newline
 Gets the high 32 bits as a signed integer.
\item Long\#$\ast$$\ast$get\+High\+Bits\+Unsigned$\ast$$\ast$()\+: {\ttfamily number}~\newline
 Gets the high 32 bits as an unsigned integer.
\item Long\#$\ast$$\ast$get\+Low\+Bits$\ast$$\ast$()\+: {\ttfamily number}~\newline
 Gets the low 32 bits as a signed integer.
\item Long\#$\ast$$\ast$get\+Low\+Bits\+Unsigned$\ast$$\ast$()\+: {\ttfamily number}~\newline
 Gets the low 32 bits as an unsigned integer.
\item Long\#$\ast$$\ast$get\+Num\+Bits\+Abs$\ast$$\ast$()\+: {\ttfamily number}~\newline
 Gets the number of bits needed to represent the absolute value of this Long.
\item Long\#$\ast$$\ast$greater\+Than$\ast$$\ast$/$\ast$$\ast$gt$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value is greater than the specified\textquotesingle{}s.
\item Long\#$\ast$$\ast$greater\+Than\+Or\+Equal$\ast$$\ast$/$\ast$$\ast$gte$\ast$$\ast$/$\ast$$\ast$ge$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value is greater than or equal the specified\textquotesingle{}s.
\item Long\#$\ast$$\ast$is\+Even$\ast$$\ast$()\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value is even.
\item Long\#$\ast$$\ast$is\+Negative$\ast$$\ast$()\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value is negative.
\item Long\#$\ast$$\ast$is\+Odd$\ast$$\ast$()\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value is odd.
\item Long\#$\ast$$\ast$is\+Positive$\ast$$\ast$()\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value is positive.
\item Long\#$\ast$$\ast$is\+Zero$\ast$$\ast$/$\ast$$\ast$eqz$\ast$$\ast$()\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value equals zero.
\item Long\#$\ast$$\ast$less\+Than$\ast$$\ast$/$\ast$$\ast$lt$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value is less than the specified\textquotesingle{}s.
\item Long\#$\ast$$\ast$less\+Than\+Or\+Equal$\ast$$\ast$/$\ast$$\ast$lte$\ast$$\ast$/$\ast$$\ast$le$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value is less than or equal the specified\textquotesingle{}s.
\item Long\#$\ast$$\ast$modulo$\ast$$\ast$/$\ast$$\ast$mod$\ast$$\ast$/$\ast$$\ast$rem$\ast$$\ast$(divisor\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns this Long modulo the specified.
\item Long\#$\ast$$\ast$multiply$\ast$$\ast$/$\ast$$\ast$mul$\ast$$\ast$(multiplier\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns the product of this and the specified Long.
\item Long\#$\ast$$\ast$negate$\ast$$\ast$/$\ast$$\ast$neg$\ast$$\ast$()\+: {\ttfamily Long}~\newline
 Negates this Long\textquotesingle{}s value.
\item Long\#$\ast$$\ast$not$\ast$$\ast$()\+: {\ttfamily Long}~\newline
 Returns the bitwise NOT of this Long.
\item Long\#$\ast$$\ast$not\+Equals$\ast$$\ast$/$\ast$$\ast$neq$\ast$$\ast$/$\ast$$\ast$ne$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily boolean}~\newline
 Tests if this Long\textquotesingle{}s value differs from the specified\textquotesingle{}s.
\item Long\#$\ast$$\ast$or$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns the bitwise OR of this Long and the specified.
\item Long\#$\ast$$\ast$shift\+Left$\ast$$\ast$/$\ast$$\ast$shl$\ast$$\ast$(num\+Bits\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns this Long with bits shifted to the left by the given amount.
\item Long\#$\ast$$\ast$shift\+Right$\ast$$\ast$/$\ast$$\ast$shr$\ast$$\ast$(num\+Bits\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns this Long with bits arithmetically shifted to the right by the given amount.
\item Long\#$\ast$$\ast$shift\+Right\+Unsigned$\ast$$\ast$/$\ast$$\ast$shru$\ast$$\ast$/$\ast$$\ast$shr\+\_\+u$\ast$$\ast$(num\+Bits\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns this Long with bits logically shifted to the right by the given amount.
\item Long\#$\ast$$\ast$rotate\+Left$\ast$$\ast$/$\ast$$\ast$rotl$\ast$$\ast$(num\+Bits\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns this Long with bits rotated to the left by the given amount.
\item Long\#$\ast$$\ast$rotate\+Right$\ast$$\ast$/$\ast$$\ast$rotr$\ast$$\ast$(num\+Bits\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns this Long with bits rotated to the right by the given amount.
\item Long\#$\ast$$\ast$subtract$\ast$$\ast$/$\ast$$\ast$sub$\ast$$\ast$(subtrahend\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns the difference of this and the specified Long.
\item Long\#$\ast$$\ast$to\+Bytes$\ast$$\ast$(le?\+: {\ttfamily boolean})\+: {\ttfamily number\mbox{[}\mbox{]}}~\newline
 Converts this Long to its byte representation.
\item Long\#$\ast$$\ast$to\+Bytes\+LE$\ast$$\ast$()\+: {\ttfamily number\mbox{[}\mbox{]}}~\newline
 Converts this Long to its little endian byte representation.
\item Long\#$\ast$$\ast$to\+Bytes\+BE$\ast$$\ast$()\+: {\ttfamily number\mbox{[}\mbox{]}}~\newline
 Converts this Long to its big endian byte representation.
\item Long\#$\ast$$\ast$to\+Int$\ast$$\ast$()\+: {\ttfamily number}~\newline
 Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
\item Long\#$\ast$$\ast$to\+Number$\ast$$\ast$()\+: {\ttfamily number}~\newline
 Converts the Long to a the nearest floating-\/point representation of this value (double, 53 bit mantissa).
\item Long\#$\ast$$\ast$to\+Signed$\ast$$\ast$()\+: {\ttfamily Long}~\newline
 Converts this Long to signed.
\item Long\#$\ast$$\ast$to\+String$\ast$$\ast$(radix?\+: {\ttfamily number})\+: {\ttfamily string}~\newline
 Converts the Long to a string written in the specified radix.
\item Long\#$\ast$$\ast$to\+Unsigned$\ast$$\ast$()\+: {\ttfamily Long}~\newline
 Converts this Long to unsigned.
\item Long\#$\ast$$\ast$xor$\ast$$\ast$(other\+: {\ttfamily Long $\vert$ number $\vert$ string})\+: {\ttfamily Long}~\newline
 Returns the bitwise XOR of this Long and the given one.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2319}{}\doxysection{Web\+Assembly support}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2319}
\href{http://webassembly.org}{\texttt{ Web\+Assembly}} supports 64-\/bit integer arithmetic out of the box, hence a \href{./src/wasm.wat}{\texttt{ tiny Web\+Assembly module}} is used to compute operations like multiplication, division and remainder more efficiently (slow operations like division are around twice as fast), falling back to floating point based computations in Java\+Script where Web\+Assembly is not yet supported, e.\+g., in older versions of node.\hypertarget{md_sfcode_node_modules__xtuc_long_README_autotoc_md2320}{}\doxysection{Building}\label{md_sfcode_node_modules__xtuc_long_README_autotoc_md2320}
To build an UMD bundle to {\ttfamily dist/long.\+js}, run\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$> npm install}
\DoxyCodeLine{\$> npm run build }

\end{DoxyCode}


Running the \href{./tests}{\texttt{ tests}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$> npm test }

\end{DoxyCode}
 