001/**
002 * AbstractLongPrimitive.java
003 * 
004 * Copyright (c) 2004-2012, Nicole C. Tedesco. All rights reserved.
005 * 
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007 * use this file except in compliance with the License. You may obtain a copy of
008 * the License at:
009 * 
010 * http://www.apache.org/licenses/LICENSE-2.0
011 * 
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015 * License for the specific language governing permissions and limitations under
016 * the License.
017 */
018
019package net.sf.jaccumulator.longs;
020
021import java.math.BigDecimal;
022import java.math.BigInteger;
023import java.util.NoSuchElementException;
024
025import net.sf.jaccumulator.Domain;
026import net.sf.jaccumulator.lex.To;
027import net.sf.jaccumulator.primitives.AbstractNumericPrimitive;
028import net.sf.jaccumulator.primitives.Constant;
029import net.sf.jaccumulator.primitives.Primitive;
030import net.sf.jaccumulator.primitives.SealedPrimitive;
031import net.sf.jaccumulator.reals.Real;
032import net.sf.jaccumulator.reals.SealedReal;
033import net.sf.jaccumulator.scalars.NumericPrecision;
034import net.sf.jaccumulator.scalars.RoundingStrategy;
035import net.sf.jaccumulator.scalars.Scalar;
036import net.sf.jaccumulator.scalars.SealedScalar;
037
038/**
039 * Abstract {@code long} precision {@link Primitive primitive} implementation
040 * 
041 * @param <PRIMITIVE>
042 *        this primitive type (used to facilitate operation chaining on write
043 *        operations)
044 * @since JAccumulator 4.0
045 * @author Nicole Tedesco (<a
046 *         href="mailto:Nicole@NicoleTedesco.com">Nicole@NicoleTedesco.com</a>)
047 */
048public abstract class AbstractLongPrimitive<PRIMITIVE extends Primitive<PRIMITIVE>>
049    extends
050        AbstractNumericPrimitive<PRIMITIVE>
051{
052    private static final long serialVersionUID = -8285080138444695275L;
053
054    public AbstractLongPrimitive()
055    {
056        super(NumericPrecision.LONG);
057    }
058
059    public AbstractLongPrimitive( final Domain aDomain )
060    {
061        super(aDomain, NumericPrecision.LONG);
062    }
063
064    @Override
065    public final PRIMITIVE absoluteValue()
066        throws UnsupportedOperationException,
067            ArithmeticException,
068            IllegalArgumentException
069    {
070        return this.setScalar(Math.abs(this.longValue()));
071    }
072
073    @Override
074    public final PRIMITIVE and( final boolean aValue )
075        throws UnsupportedOperationException,
076            IllegalArgumentException,
077            ArithmeticException
078    {
079        return this.and(To.longValue(aValue));
080    }
081
082    @Override
083    public final PRIMITIVE and( final byte aValue )
084        throws UnsupportedOperationException,
085            IllegalArgumentException,
086            ArithmeticException
087    {
088        return this.setScalar(this.longValue() & aValue);
089    }
090
091    @Override
092    public final PRIMITIVE and( final char aValue )
093        throws UnsupportedOperationException,
094            IllegalArgumentException,
095            ArithmeticException
096    {
097        return this.setScalar(this.longValue() & aValue);
098    }
099
100    @Override
101    public final PRIMITIVE and( final int aValue )
102        throws UnsupportedOperationException,
103            IllegalArgumentException,
104            ArithmeticException
105    {
106        return this.setScalar(this.longValue() & aValue);
107    }
108
109    @Override
110    public final PRIMITIVE and( final short aValue )
111        throws UnsupportedOperationException,
112            IllegalArgumentException,
113            ArithmeticException
114    {
115        return this.setScalar(this.longValue() & aValue);
116    }
117
118    @Override
119    public final boolean booleanPostDecrement()
120        throws UnsupportedOperationException,
121            ArithmeticException,
122            IllegalArgumentException
123    {
124        return To.booleanValue(this.longPostDecrement());
125    }
126
127    @Override
128    public final boolean booleanPostIncrement()
129        throws UnsupportedOperationException,
130            ArithmeticException,
131            IllegalArgumentException
132    {
133        return To.booleanValue(this.longPostIncrement());
134    }
135
136    @Override
137    public final boolean booleanValue()
138    {
139        return To.booleanValue(this.longValue());
140    }
141
142    @Override
143    public final byte bytePostDecrement()
144        throws UnsupportedOperationException,
145            ArithmeticException,
146            IllegalArgumentException
147    {
148        return (byte)this.longPostDecrement();
149    }
150
151    @Override
152    public final byte bytePostIncrement()
153        throws UnsupportedOperationException,
154            ArithmeticException,
155            IllegalArgumentException
156    {
157        return (byte)this.longPostIncrement();
158    }
159
160    @Override
161    public final byte byteValue()
162    {
163        return (byte)this.longValue();
164    }
165
166    @Override
167    public final char charPostDecrement()
168        throws UnsupportedOperationException,
169            ArithmeticException,
170            IllegalArgumentException
171    {
172        return (char)this.longPostDecrement();
173    }
174
175    @Override
176    public final char charPostIncrement()
177        throws UnsupportedOperationException,
178            ArithmeticException,
179            IllegalArgumentException
180    {
181        return (char)this.longPostIncrement();
182    }
183
184    @Override
185    public final char charValue()
186    {
187        return (char)this.longValue();
188    }
189
190    @Override
191    public final PRIMITIVE copyUsing( final BigDecimal aValue )
192    {
193        return this.copyUsing(aValue.longValue());
194    }
195
196    @Override
197    public final PRIMITIVE copyUsing( final BigInteger aValue )
198    {
199        return this.copyUsing(aValue.longValue());
200    }
201
202    @Override
203    public final PRIMITIVE copyUsing( final boolean aValue )
204    {
205        return this.copyUsing(To.longValue(aValue));
206    }
207
208    @Override
209    public final PRIMITIVE copyUsing( final byte aValue )
210    {
211        return this.copyUsing((long)aValue);
212    }
213
214    @Override
215    public final PRIMITIVE copyUsing( final char aValue )
216    {
217        return this.copyUsing((long)aValue);
218    }
219
220    @Override
221    public final PRIMITIVE copyUsing( final double aValue )
222    {
223        return this.copyUsing((long)aValue);
224    }
225
226    @Override
227    public final PRIMITIVE copyUsing( final float aValue )
228    {
229        return this.copyUsing((long)aValue);
230    }
231
232    @Override
233    public final PRIMITIVE copyUsing( final int aValue )
234    {
235        return this.copyUsing((long)aValue);
236    }
237
238    @Override
239    public final PRIMITIVE copyUsing( final short aValue )
240    {
241        return this.copyUsing((long)aValue);
242    }
243
244    @Override
245    public final PRIMITIVE copyUsingPrimitive( final SealedPrimitive<?> aValue )
246    {
247        return this.copyUsing(aValue.longValue());
248    }
249
250    @Override
251    public final PRIMITIVE copyUsingReal( final SealedReal<?> aValue )
252    {
253        return this.copyUsing(aValue.longValue());
254    }
255
256    @Override
257    public final PRIMITIVE copyUsingScalar( final SealedScalar<?> aValue )
258    {
259        return this.copyUsing(aValue.longValue());
260    }
261
262    @Override
263    public final PRIMITIVE cube()
264        throws UnsupportedOperationException,
265            IllegalArgumentException,
266            ArithmeticException
267    {
268        final long myValue = this.longValue();
269        return this.setScalar(myValue * myValue * myValue);
270    }
271
272    @Override
273    public final PRIMITIVE difference( final boolean aValue )
274        throws UnsupportedOperationException,
275            IllegalArgumentException,
276            ArithmeticException
277    {
278        return this.difference(To.longValue(aValue));
279    }
280
281    @Override
282    public final PRIMITIVE difference( final byte aValue )
283        throws UnsupportedOperationException,
284            IllegalArgumentException,
285            ArithmeticException
286    {
287        return this.setScalar(this.longValue() - aValue);
288    }
289
290    @Override
291    public final PRIMITIVE difference( final char aValue )
292        throws UnsupportedOperationException,
293            IllegalArgumentException,
294            ArithmeticException
295    {
296        return this.setScalar(this.longValue() - aValue);
297    }
298
299    @Override
300    public final PRIMITIVE difference( final int aValue )
301        throws UnsupportedOperationException,
302            IllegalArgumentException,
303            ArithmeticException
304    {
305        return this.setScalar(this.longValue() - aValue);
306    }
307
308    @Override
309    public final PRIMITIVE difference( final short aValue )
310        throws UnsupportedOperationException,
311            IllegalArgumentException,
312            ArithmeticException
313    {
314        return this.setScalar(this.longValue() - aValue);
315    }
316
317    @Override
318    public final double doublePostDecrement()
319        throws UnsupportedOperationException,
320            ArithmeticException,
321            IllegalArgumentException
322    {
323        return this.longPostDecrement();
324    }
325
326    @Override
327    public final double doublePostIncrement()
328        throws UnsupportedOperationException,
329            ArithmeticException,
330            IllegalArgumentException
331    {
332        return this.longPostIncrement();
333    }
334
335    @Override
336    public final double doubleValue()
337    {
338        return this.longValue();
339    }
340
341    @Override
342    public final float floatPostDecrement()
343        throws UnsupportedOperationException,
344            ArithmeticException,
345            IllegalArgumentException
346    {
347        return this.longPostDecrement();
348    }
349
350    @Override
351    public final float floatPostIncrement()
352        throws UnsupportedOperationException,
353            ArithmeticException,
354            IllegalArgumentException
355    {
356        return this.longPostIncrement();
357    }
358
359    @Override
360    public final float floatValue()
361    {
362        return this.longValue();
363    }
364
365    @Override
366    @SuppressWarnings( "unchecked" )
367    public final <S extends Scalar<?>> S inducePostDecrement( final S aTarget )
368        throws NullPointerException,
369            NoSuchElementException,
370            UnsupportedOperationException,
371            IllegalStateException
372    {
373        return (S)aTarget.setScalar(this.longPostDecrement());
374    }
375
376    @Override
377    @SuppressWarnings( "unchecked" )
378    public final <S extends Scalar<?>> S inducePostIncrement( final S aTarget )
379        throws NullPointerException,
380            NoSuchElementException,
381            UnsupportedOperationException,
382            IllegalStateException
383    {
384        return (S)aTarget.setScalar(this.longPostIncrement());
385    }
386
387    @Override
388    public final <REAL extends Real<?>> REAL induceRealMaximum(
389        final REAL aTarget )
390        throws NullPointerException,
391            NoSuchElementException,
392            UnsupportedOperationException,
393            IllegalStateException
394    {
395        return this.induceScalarMaximum(aTarget);
396    }
397
398    @Override
399    public final <REAL extends Real<?>> REAL induceRealMinimum(
400        final REAL aTarget )
401        throws NullPointerException,
402            NoSuchElementException,
403            UnsupportedOperationException,
404            IllegalStateException
405    {
406        return this.induceScalarMinimum(aTarget);
407    }
408
409    @Override
410    public final <REAL extends Real<?>> REAL induceRealValue( final REAL aTarget )
411        throws NullPointerException,
412            NoSuchElementException,
413            UnsupportedOperationException,
414            IllegalStateException
415    {
416        return this.induceScalarValue(aTarget);
417    }
418
419    @Override
420    @SuppressWarnings( "unchecked" )
421    public final <S extends Scalar<?>> S induceScalarMaximum( final S aTarget )
422    {
423        return (S)aTarget.setScalar(Long.MAX_VALUE);
424    }
425
426    @Override
427    @SuppressWarnings( "unchecked" )
428    public final <S extends Scalar<?>> S induceScalarMinimum( final S aTarget )
429    {
430        return (S)aTarget.setScalar(Long.MIN_VALUE);
431    }
432
433    @Override
434    @SuppressWarnings( "unchecked" )
435    public final <S extends Scalar<?>> S induceScalarValue( final S aTarget )
436    {
437        return (S)aTarget.setScalar(this.longValue());
438    }
439
440    @Override
441    public final int intPostDecrement()
442        throws UnsupportedOperationException,
443            ArithmeticException,
444            IllegalArgumentException
445    {
446        return (int)this.longPostDecrement();
447    }
448
449    @Override
450    public final int intPostIncrement()
451        throws UnsupportedOperationException,
452            ArithmeticException,
453            IllegalArgumentException
454    {
455        return (int)this.longPostIncrement();
456    }
457
458    @Override
459    public final int intValue()
460    {
461        return (int)this.longValue();
462    }
463
464    @Override
465    public final PRIMITIVE inverse()
466        throws UnsupportedOperationException,
467            ArithmeticException,
468            IllegalArgumentException
469    {
470        if (this.isZero()) return this.quotient(0);
471        return this.setUnity();
472    }
473
474    @Override
475    public final boolean isFinite()
476    {
477        return true;
478    }
479
480    @Override
481    public final boolean isInfinity()
482    {
483        return false;
484    }
485
486    @Override
487    public final boolean isInvalid()
488    {
489        return false;
490    }
491
492    @Override
493    public final boolean isMaximum()
494    {
495        return this.longValue() == Long.MAX_VALUE;
496    }
497
498    @Override
499    public final boolean isMinimum()
500    {
501        return this.longValue() == Long.MIN_VALUE;
502    }
503
504    @Override
505    public final boolean isModulo()
506    {
507        return false;
508    }
509
510    @Override
511    public final boolean isNegative()
512    {
513        return this.longValue() < 0L;
514    }
515
516    @Override
517    public final boolean isNegativeFinite()
518    {
519        return this.isNegative();
520    }
521
522    @Override
523    public final boolean isNegativeInfinity()
524    {
525        return false;
526    }
527
528    @Override
529    public final boolean isPositive()
530    {
531        return 0L < this.longValue();
532    }
533
534    @Override
535    public final boolean isPositiveFinite()
536    {
537        return this.isPositive();
538    }
539
540    @Override
541    public final boolean isPositiveInfinity()
542    {
543        return false;
544    }
545
546    @Override
547    public final boolean isReal()
548    {
549        return true;
550    }
551
552    @Override
553    public final boolean isUnity()
554    {
555        return this.longValue() == 1L;
556    }
557
558    @Override
559    public final boolean isZero()
560    {
561        return this.longValue() == 0L;
562    }
563
564    @Override
565    public final PRIMITIVE negate()
566        throws UnsupportedOperationException,
567            ArithmeticException,
568            IllegalArgumentException
569    {
570        return this.setScalar(-this.longValue());
571    }
572
573    @Override
574    public final PRIMITIVE or( final boolean aValue )
575        throws UnsupportedOperationException,
576            IllegalArgumentException,
577            ArithmeticException
578    {
579        return this.or(To.longValue(aValue));
580    }
581
582    @Override
583    public final PRIMITIVE or( final byte aValue )
584        throws UnsupportedOperationException,
585            IllegalArgumentException,
586            ArithmeticException
587    {
588        return this.setScalar(this.longValue() | aValue);
589    }
590
591    @Override
592    public final PRIMITIVE or( final char aValue )
593        throws UnsupportedOperationException,
594            IllegalArgumentException,
595            ArithmeticException
596    {
597        return this.setScalar(this.longValue() | aValue);
598    }
599
600    @Override
601    public final PRIMITIVE or( final int aValue )
602        throws UnsupportedOperationException,
603            IllegalArgumentException,
604            ArithmeticException
605    {
606        return this.setScalar(this.longValue() | aValue);
607    }
608
609    @Override
610    public final PRIMITIVE or( final short aValue )
611        throws UnsupportedOperationException,
612            IllegalArgumentException,
613            ArithmeticException
614    {
615        return this.setScalar(this.longValue() | aValue);
616    }
617
618    @Override
619    public final PRIMITIVE product( final boolean aValue )
620        throws UnsupportedOperationException,
621            IllegalArgumentException,
622            ArithmeticException
623    {
624        return this.product(To.longValue(aValue));
625    }
626
627    @Override
628    public final PRIMITIVE product( final byte aValue )
629        throws UnsupportedOperationException,
630            IllegalArgumentException,
631            ArithmeticException
632    {
633        return this.setScalar(this.longValue() * aValue);
634    }
635
636    @Override
637    public final PRIMITIVE product( final char aValue )
638        throws UnsupportedOperationException,
639            IllegalArgumentException,
640            ArithmeticException
641    {
642        return this.setScalar(this.longValue() * aValue);
643    }
644
645    @Override
646    public final PRIMITIVE product( final int aValue )
647        throws UnsupportedOperationException,
648            IllegalArgumentException,
649            ArithmeticException
650    {
651        return this.setScalar(this.longValue() * aValue);
652    }
653
654    @Override
655    public final PRIMITIVE product( final short aValue )
656        throws UnsupportedOperationException,
657            IllegalArgumentException,
658            ArithmeticException
659    {
660        return this.setScalar(this.longValue() * aValue);
661    }
662
663    @Override
664    public final PRIMITIVE quotient( final boolean aValue )
665        throws UnsupportedOperationException,
666            IllegalArgumentException,
667            ArithmeticException
668    {
669        return this.quotient(To.longValue(aValue));
670    }
671
672    @Override
673    public final PRIMITIVE quotient( final byte aValue )
674        throws UnsupportedOperationException,
675            IllegalArgumentException,
676            ArithmeticException
677    {
678        return this.setScalar(this.longValue() / aValue);
679    }
680
681    @Override
682    public final PRIMITIVE quotient( final char aValue )
683        throws UnsupportedOperationException,
684            IllegalArgumentException,
685            ArithmeticException
686    {
687        return this.setScalar(this.longValue() / aValue);
688    }
689
690    @Override
691    public final PRIMITIVE quotient( final int aValue )
692        throws UnsupportedOperationException,
693            IllegalArgumentException,
694            ArithmeticException
695    {
696        return this.setScalar(this.longValue() / aValue);
697    }
698
699    @Override
700    public final PRIMITIVE quotient( final short aValue )
701        throws UnsupportedOperationException,
702            IllegalArgumentException,
703            ArithmeticException
704    {
705        return this.setScalar(this.longValue() / aValue);
706    }
707
708    @Override
709    @SuppressWarnings( "unchecked" )
710    public final PRIMITIVE round( final RoundingStrategy aRoundingStrategy )
711        throws UnsupportedOperationException,
712            IllegalArgumentException,
713            ArithmeticException,
714            NullPointerException
715    {
716        return (PRIMITIVE)this;
717    }
718
719    @Override
720    public final PRIMITIVE setMaximum()
721        throws UnsupportedOperationException,
722            ArithmeticException,
723            IllegalArgumentException
724    {
725        return this.setScalar(Long.MAX_VALUE);
726    }
727
728    @Override
729    public final PRIMITIVE setMinimum()
730        throws UnsupportedOperationException,
731            ArithmeticException,
732            IllegalArgumentException
733    {
734        return this.setScalar(Long.MIN_VALUE);
735    }
736
737    @Override
738    public final PRIMITIVE setNumber( final Number aValue )
739        throws UnsupportedOperationException,
740            IllegalArgumentException,
741            ArithmeticException,
742            NullPointerException
743    {
744        return this.setScalar(aValue.longValue());
745    }
746
747    @Override
748    public final PRIMITIVE setPrimitive( final SealedPrimitive<?> aValue )
749        throws UnsupportedOperationException,
750            IllegalArgumentException,
751            ArithmeticException,
752            NullPointerException
753    {
754        return this.setScalar(aValue.longValue());
755    }
756
757    @Override
758    public final PRIMITIVE setReal( final BigDecimal aValue )
759        throws UnsupportedOperationException,
760            IllegalArgumentException,
761            ArithmeticException,
762            NullPointerException
763    {
764        return this.setScalar(aValue.longValue());
765    }
766
767    @Override
768    public final PRIMITIVE setReal( final BigInteger aValue )
769        throws UnsupportedOperationException,
770            IllegalArgumentException,
771            ArithmeticException,
772            NullPointerException
773    {
774        return this.setScalar(aValue.longValue());
775    }
776
777    @Override
778    public final PRIMITIVE setReal( final SealedReal<?> aValue )
779        throws UnsupportedOperationException,
780            IllegalArgumentException,
781            ArithmeticException,
782            NullPointerException
783    {
784        return this.setScalar(aValue.longValue());
785    }
786
787    @Override
788    public final PRIMITIVE setScalar( final boolean aValue )
789        throws UnsupportedOperationException,
790            IllegalArgumentException,
791            ArithmeticException
792    {
793        return this.setScalar(To.longValue(aValue));
794    }
795
796    @Override
797    public final PRIMITIVE setScalar( final byte aValue )
798        throws UnsupportedOperationException,
799            IllegalArgumentException,
800            ArithmeticException
801    {
802        return this.setScalar((long)aValue);
803    }
804
805    @Override
806    public final PRIMITIVE setScalar( final char aValue )
807        throws UnsupportedOperationException,
808            IllegalArgumentException,
809            ArithmeticException
810    {
811        return this.setScalar((long)aValue);
812    }
813
814    @Override
815    public final PRIMITIVE setScalar( final double aValue )
816        throws UnsupportedOperationException,
817            IllegalArgumentException,
818            ArithmeticException
819    {
820        return this.setScalar((long)aValue);
821    }
822
823    @Override
824    public final PRIMITIVE setScalar( final float aValue )
825        throws UnsupportedOperationException,
826            IllegalArgumentException,
827            ArithmeticException
828    {
829        return this.setScalar((long)aValue);
830    }
831
832    @Override
833    public final PRIMITIVE setScalar( final int aValue )
834        throws UnsupportedOperationException,
835            IllegalArgumentException,
836            ArithmeticException
837    {
838        return this.setScalar((long)aValue);
839    }
840
841    @Override
842    public final PRIMITIVE setScalar( final SealedScalar<?> aValue )
843        throws UnsupportedOperationException,
844            IllegalArgumentException,
845            ArithmeticException,
846            NullPointerException
847    {
848        return this.setScalar(aValue.longValue());
849    }
850
851    @Override
852    public final PRIMITIVE setScalar( final short aValue )
853        throws UnsupportedOperationException,
854            IllegalArgumentException,
855            ArithmeticException
856    {
857        return this.setScalar((long)aValue);
858    }
859
860    @Override
861    public final PRIMITIVE setUnity()
862        throws UnsupportedOperationException,
863            IllegalArgumentException,
864            ArithmeticException
865    {
866        return this.setScalar(1L);
867    }
868
869    @Override
870    public final PRIMITIVE setZero()
871        throws UnsupportedOperationException,
872            IllegalArgumentException,
873            ArithmeticException
874    {
875        return this.setScalar(0L);
876    }
877
878    @Override
879    public final short shortPostDecrement()
880        throws UnsupportedOperationException,
881            ArithmeticException,
882            IllegalArgumentException
883    {
884        return (short)this.longPostDecrement();
885    }
886
887    @Override
888    public final short shortPostIncrement()
889        throws UnsupportedOperationException,
890            ArithmeticException,
891            IllegalArgumentException
892    {
893        return (short)this.longPostIncrement();
894    }
895
896    @Override
897    public final short shortValue()
898    {
899        return (short)this.longValue();
900    }
901
902    @Override
903    public final PRIMITIVE square()
904        throws UnsupportedOperationException,
905            IllegalArgumentException,
906            ArithmeticException
907    {
908        final long myValue = this.longValue();
909        return this.setScalar(myValue * myValue);
910    }
911
912    @Override
913    public final PRIMITIVE sum( final boolean aValue )
914        throws UnsupportedOperationException,
915            IllegalArgumentException,
916            ArithmeticException
917    {
918        return this.sum(To.longValue(aValue));
919    }
920
921    @Override
922    public final PRIMITIVE sum( final byte aValue )
923        throws UnsupportedOperationException,
924            IllegalArgumentException,
925            ArithmeticException
926    {
927        return this.setScalar(this.longValue() + aValue);
928    }
929
930    @Override
931    public final PRIMITIVE sum( final char aValue )
932        throws UnsupportedOperationException,
933            IllegalArgumentException,
934            ArithmeticException
935    {
936        return this.setScalar(this.longValue() + aValue);
937    }
938
939    @Override
940    public final PRIMITIVE sum( final int aValue )
941        throws UnsupportedOperationException,
942            IllegalArgumentException,
943            ArithmeticException
944    {
945        return this.setScalar(this.longValue() + aValue);
946    }
947
948    @Override
949    public final PRIMITIVE sum( final short aValue )
950        throws UnsupportedOperationException,
951            IllegalArgumentException,
952            ArithmeticException
953    {
954        return this.setScalar(this.longValue() + aValue);
955    }
956
957    @Override
958    public final PRIMITIVE swapPrimitives( final Primitive<?> aPrimitive )
959    {
960        final long myValue = this.longValue();
961        final long aValue = aPrimitive.longValue();
962        aPrimitive.setScalar(myValue);
963        return this.setScalar(aValue);
964    }
965
966    @Override
967    public final Number toNumber()
968    {
969        return Long.valueOf(this.longValue());
970    }
971
972    @Override
973    public String toString()
974    {
975        return String.valueOf(this.longValue());
976    }
977
978    @Override
979    public final BigDecimal toUnlimitedDecimal()
980    {
981        return Constant.toUnlimitedDecimal(this.longValue());
982    }
983
984    @Override
985    public final BigInteger toUnlimitedInteger()
986    {
987        return BigInteger.valueOf(this.longValue());
988    }
989
990    @Override
991    public final BigDecimal unlimitedDecimalPostDecrement()
992        throws UnsupportedOperationException,
993            ArithmeticException,
994            IllegalArgumentException
995    {
996        return Constant.toUnlimitedDecimal(this.longPostDecrement());
997    }
998
999    @Override
1000    public final BigDecimal unlimitedDecimalPostIncrement()
1001        throws UnsupportedOperationException,
1002            ArithmeticException,
1003            IllegalArgumentException
1004    {
1005        return Constant.toUnlimitedDecimal(this.longPostIncrement());
1006    }
1007
1008    @Override
1009    public final BigInteger unlimitedIntegerPostDecrement()
1010        throws UnsupportedOperationException,
1011            ArithmeticException,
1012            IllegalArgumentException
1013    {
1014        return Constant.toUnlimitedInteger(this.longPostDecrement());
1015    }
1016
1017    @Override
1018    public final BigInteger unlimitedIntegerPostIncrement()
1019        throws UnsupportedOperationException,
1020            ArithmeticException,
1021            IllegalArgumentException
1022    {
1023        return Constant.toUnlimitedInteger(this.longPostIncrement());
1024    }
1025
1026    @Override
1027    public final PRIMITIVE xor( final boolean aValue )
1028        throws UnsupportedOperationException,
1029            IllegalArgumentException,
1030            ArithmeticException
1031    {
1032        return this.xor(To.longValue(aValue));
1033    }
1034
1035    @Override
1036    public final PRIMITIVE xor( final byte aValue )
1037        throws UnsupportedOperationException,
1038            IllegalArgumentException,
1039            ArithmeticException
1040    {
1041        return this.setScalar(this.longValue() ^ aValue);
1042    }
1043
1044    @Override
1045    public final PRIMITIVE xor( final char aValue )
1046        throws UnsupportedOperationException,
1047            IllegalArgumentException,
1048            ArithmeticException
1049    {
1050        return this.setScalar(this.longValue() ^ aValue);
1051    }
1052
1053    @Override
1054    public final PRIMITIVE xor( final int aValue )
1055        throws UnsupportedOperationException,
1056            IllegalArgumentException,
1057            ArithmeticException
1058    {
1059        return this.setScalar(this.longValue() ^ aValue);
1060    }
1061
1062    @Override
1063    public final PRIMITIVE xor( final short aValue )
1064        throws UnsupportedOperationException,
1065            IllegalArgumentException,
1066            ArithmeticException
1067    {
1068        return this.setScalar(this.longValue() ^ aValue);
1069    }
1070}