001/**
002 * AbstractFloatPrimitive.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.floats;
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 float} 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 AbstractFloatPrimitive<PRIMITIVE extends Primitive<PRIMITIVE>>
049    extends
050        AbstractNumericPrimitive<PRIMITIVE>
051{
052    private static final long serialVersionUID = -9042043712425675288L;
053
054    public AbstractFloatPrimitive()
055    {
056        super(NumericPrecision.FLOAT);
057    }
058
059    public AbstractFloatPrimitive( final Domain aDomain )
060    {
061        super(aDomain, NumericPrecision.FLOAT);
062    }
063
064    @Override
065    public final PRIMITIVE absoluteValue()
066        throws UnsupportedOperationException,
067            ArithmeticException,
068            IllegalArgumentException
069    {
070        return this.setScalar(Math.abs(this.floatValue()));
071    }
072
073    @Override
074    public final PRIMITIVE and( final BigInteger aValue )
075        throws UnsupportedOperationException,
076            IllegalArgumentException,
077            ArithmeticException
078    {
079        return this.setReal(this.toUnlimitedInteger().and(aValue));
080    }
081
082    @Override
083    public final PRIMITIVE and( final boolean aValue )
084        throws UnsupportedOperationException,
085            IllegalArgumentException,
086            ArithmeticException
087    {
088        return this.and(Constant.toUnlimitedInteger(aValue));
089    }
090
091    @Override
092    public final PRIMITIVE and( final byte aValue )
093        throws UnsupportedOperationException,
094            IllegalArgumentException,
095            ArithmeticException
096    {
097        return this.and(BigInteger.valueOf(aValue));
098    }
099
100    @Override
101    public final PRIMITIVE and( final char aValue )
102        throws UnsupportedOperationException,
103            IllegalArgumentException,
104            ArithmeticException
105    {
106        return this.and(BigInteger.valueOf(aValue));
107    }
108
109    @Override
110    public final PRIMITIVE and( final int aValue )
111        throws UnsupportedOperationException,
112            IllegalArgumentException,
113            ArithmeticException
114    {
115        return this.and(BigInteger.valueOf(aValue));
116    }
117
118    @Override
119    public final PRIMITIVE and( final long aValue )
120        throws UnsupportedOperationException,
121            IllegalArgumentException,
122            ArithmeticException
123    {
124        return this.and(BigInteger.valueOf(aValue));
125    }
126
127    @Override
128    public final PRIMITIVE and( final short aValue )
129        throws UnsupportedOperationException,
130            IllegalArgumentException,
131            ArithmeticException
132    {
133        return this.and(BigInteger.valueOf(aValue));
134    }
135
136    @Override
137    public final boolean booleanPostDecrement()
138        throws UnsupportedOperationException,
139            ArithmeticException,
140            IllegalArgumentException
141    {
142        return To.booleanValue(this.floatPostDecrement());
143    }
144
145    @Override
146    public final boolean booleanPostIncrement()
147        throws UnsupportedOperationException,
148            ArithmeticException,
149            IllegalArgumentException
150    {
151        return To.booleanValue(this.floatPostIncrement());
152    }
153
154    @Override
155    public final boolean booleanValue()
156    {
157        return To.booleanValue(this.floatValue());
158    }
159
160    @Override
161    public final byte bytePostDecrement()
162        throws UnsupportedOperationException,
163            ArithmeticException,
164            IllegalArgumentException
165    {
166        return (byte)this.floatPostDecrement();
167    }
168
169    @Override
170    public final byte bytePostIncrement()
171        throws UnsupportedOperationException,
172            ArithmeticException,
173            IllegalArgumentException
174    {
175        return (byte)this.floatPostIncrement();
176    }
177
178    @Override
179    public final byte byteValue()
180    {
181        return (byte)this.floatValue();
182    }
183
184    @Override
185    public final char charPostDecrement()
186        throws UnsupportedOperationException,
187            ArithmeticException,
188            IllegalArgumentException
189    {
190        return (char)this.floatPostDecrement();
191    }
192
193    @Override
194    public final char charPostIncrement()
195        throws UnsupportedOperationException,
196            ArithmeticException,
197            IllegalArgumentException
198    {
199        return (char)this.floatPostIncrement();
200    }
201
202    @Override
203    public final char charValue()
204    {
205        return (char)this.floatValue();
206    }
207
208    @Override
209    public final PRIMITIVE copyUsing( final BigDecimal aValue )
210    {
211        return this.copyUsing(aValue.floatValue());
212    }
213
214    @Override
215    public final PRIMITIVE copyUsing( final BigInteger aValue )
216    {
217        return this.copyUsing(aValue.floatValue());
218    }
219
220    @Override
221    public final PRIMITIVE copyUsing( final boolean aValue )
222    {
223        return this.copyUsing(To.floatValue(aValue));
224    }
225
226    @Override
227    public final PRIMITIVE copyUsing( final byte aValue )
228    {
229        return this.copyUsing((float)aValue);
230    }
231
232    @Override
233    public final PRIMITIVE copyUsing( final char aValue )
234    {
235        return this.copyUsing((float)aValue);
236    }
237
238    @Override
239    public final PRIMITIVE copyUsing( final double aValue )
240    {
241        return this.copyUsing((float)aValue);
242    }
243
244    @Override
245    public final PRIMITIVE copyUsing( final int aValue )
246    {
247        return this.copyUsing((float)aValue);
248    }
249
250    @Override
251    public final PRIMITIVE copyUsing( final long aValue )
252    {
253        return this.copyUsing((float)aValue);
254    }
255
256    @Override
257    public final PRIMITIVE copyUsing( final short aValue )
258    {
259        return this.copyUsing((float)aValue);
260    }
261
262    @Override
263    public final PRIMITIVE copyUsingPrimitive( final SealedPrimitive<?> aValue )
264    {
265        return this.copyUsing(aValue.floatValue());
266    }
267
268    @Override
269    public final PRIMITIVE copyUsingReal( final SealedReal<?> aValue )
270    {
271        return this.copyUsing(aValue.floatValue());
272    }
273
274    @Override
275    public final PRIMITIVE copyUsingScalar( final SealedScalar<?> aValue )
276    {
277        return this.copyUsing(aValue.floatValue());
278    }
279
280    @Override
281    public final PRIMITIVE cube()
282        throws UnsupportedOperationException,
283            IllegalArgumentException,
284            ArithmeticException
285    {
286        final float myValue = this.floatValue();
287        return this.setScalar(myValue * myValue * myValue);
288    }
289
290    @Override
291    public final PRIMITIVE difference( final BigDecimal aValue )
292        throws UnsupportedOperationException,
293            IllegalArgumentException,
294            ArithmeticException
295    {
296        return this.setReal(this.toUnlimitedDecimal().subtract(aValue));
297    }
298
299    @Override
300    public final PRIMITIVE difference( final BigInteger aValue )
301        throws UnsupportedOperationException,
302            IllegalArgumentException,
303            ArithmeticException
304    {
305        return this.difference(Constant.toUnlimitedDecimal(aValue));
306    }
307
308    @Override
309    public final PRIMITIVE difference( final boolean aValue )
310        throws UnsupportedOperationException,
311            IllegalArgumentException,
312            ArithmeticException
313    {
314        return this.difference(Constant.toUnlimitedDecimal(aValue));
315    }
316
317    @Override
318    public final PRIMITIVE difference( final byte aValue )
319        throws UnsupportedOperationException,
320            IllegalArgumentException,
321            ArithmeticException
322    {
323        return this.setScalar(this.floatValue() - aValue);
324    }
325
326    @Override
327    public final PRIMITIVE difference( final char aValue )
328        throws UnsupportedOperationException,
329            IllegalArgumentException,
330            ArithmeticException
331    {
332        return this.setScalar(this.floatValue() - aValue);
333    }
334
335    @Override
336    public final PRIMITIVE difference( final int aValue )
337        throws UnsupportedOperationException,
338            IllegalArgumentException,
339            ArithmeticException
340    {
341        return this.setScalar(this.floatValue() - aValue);
342    }
343
344    @Override
345    public final PRIMITIVE difference( final long aValue )
346        throws UnsupportedOperationException,
347            IllegalArgumentException,
348            ArithmeticException
349    {
350        return this.setScalar(this.floatValue() - aValue);
351    }
352
353    @Override
354    public final PRIMITIVE difference( final short aValue )
355        throws UnsupportedOperationException,
356            IllegalArgumentException,
357            ArithmeticException
358    {
359        return this.setScalar(this.floatValue() - aValue);
360    }
361
362    @Override
363    public final double doublePostDecrement()
364        throws UnsupportedOperationException,
365            ArithmeticException,
366            IllegalArgumentException
367    {
368        return this.floatPostDecrement();
369    }
370
371    @Override
372    public final double doublePostIncrement()
373        throws UnsupportedOperationException,
374            ArithmeticException,
375            IllegalArgumentException
376    {
377        return this.floatPostIncrement();
378    }
379
380    @Override
381    public final double doubleValue()
382    {
383        return this.floatValue();
384    }
385
386    @Override
387    @SuppressWarnings( "unchecked" )
388    public final <S extends Scalar<?>> S inducePostDecrement( final S aTarget )
389        throws NullPointerException,
390            NoSuchElementException,
391            UnsupportedOperationException,
392            IllegalStateException
393    {
394        return (S)aTarget.setScalar(this.floatPostDecrement());
395    }
396
397    @Override
398    @SuppressWarnings( "unchecked" )
399    public final <S extends Scalar<?>> S inducePostIncrement( final S aTarget )
400        throws NullPointerException,
401            NoSuchElementException,
402            UnsupportedOperationException,
403            IllegalStateException
404    {
405        return (S)aTarget.setScalar(this.floatPostIncrement());
406    }
407
408    @Override
409    public final <REAL extends Real<?>> REAL induceRealMaximum(
410        final REAL aTarget )
411        throws NullPointerException,
412            NoSuchElementException,
413            UnsupportedOperationException,
414            IllegalStateException
415    {
416        return this.induceScalarMaximum(aTarget);
417    }
418
419    @Override
420    public final <REAL extends Real<?>> REAL induceRealMinimum(
421        final REAL aTarget )
422        throws NullPointerException,
423            NoSuchElementException,
424            UnsupportedOperationException,
425            IllegalStateException
426    {
427        return this.induceScalarMinimum(aTarget);
428    }
429
430    @Override
431    public final <REAL extends Real<?>> REAL induceRealValue( final REAL aTarget )
432        throws NullPointerException,
433            NoSuchElementException,
434            UnsupportedOperationException,
435            IllegalStateException
436    {
437        return this.induceScalarValue(aTarget);
438    }
439
440    @Override
441    @SuppressWarnings( "unchecked" )
442    public final <S extends Scalar<?>> S induceScalarMaximum( final S aTarget )
443    {
444        return (S)aTarget.setScalar(Float.MAX_VALUE);
445    }
446
447    @Override
448    @SuppressWarnings( "unchecked" )
449    public final <S extends Scalar<?>> S induceScalarMinimum( final S aTarget )
450    {
451        return (S)aTarget.setScalar(Float.MIN_VALUE);
452    }
453
454    @Override
455    @SuppressWarnings( "unchecked" )
456    public final <S extends Scalar<?>> S induceScalarValue( final S aTarget )
457    {
458        return (S)aTarget.setScalar(this.floatValue());
459    }
460
461    @Override
462    public final int intPostDecrement()
463        throws UnsupportedOperationException,
464            ArithmeticException,
465            IllegalArgumentException
466    {
467        return (int)this.floatPostDecrement();
468    }
469
470    @Override
471    public final int intPostIncrement()
472        throws UnsupportedOperationException,
473            ArithmeticException,
474            IllegalArgumentException
475    {
476        return (int)this.floatPostIncrement();
477    }
478
479    @Override
480    public final int intValue()
481    {
482        return (int)this.floatValue();
483    }
484
485    @Override
486    public final PRIMITIVE invalidate()
487        throws UnsupportedOperationException,
488            ArithmeticException,
489            IllegalArgumentException
490    {
491        return this.setScalar(Float.NaN);
492    }
493
494    @Override
495    public final PRIMITIVE inverse()
496        throws UnsupportedOperationException,
497            ArithmeticException,
498            IllegalArgumentException
499    {
500        return this.setScalar(1.0F / this.floatValue());
501    }
502
503    @Override
504    public final boolean isInfinity()
505    {
506        return Float.isInfinite(this.floatValue());
507    }
508
509    @Override
510    public final boolean isInvalid()
511    {
512        return Float.isNaN(this.floatValue());
513    }
514
515    @Override
516    public final boolean isMaximum()
517    {
518        return Float.compare(this.floatValue(), Float.MAX_VALUE) == 0;
519    }
520
521    @Override
522    public final boolean isMinimum()
523    {
524        return Float.compare(this.floatValue(), Float.MIN_VALUE) == 0;
525    }
526
527    @Override
528    public final boolean isModulo()
529    {
530        return false;
531    }
532
533    @Override
534    public final boolean isNegative()
535    {
536        return Float.compare(this.floatValue(), 0.0F) < 0;
537    }
538
539    @Override
540    public final boolean isNegativeFinite()
541    {
542        final Float myValue = this.floatValue();
543        if (Float.isNaN(myValue)) return false;
544        if (Float.isInfinite(myValue)) return false;
545        return myValue < 0.0F;
546    }
547
548    @Override
549    public final boolean isNegativeInfinity()
550    {
551        return this.floatValue() == Float.NEGATIVE_INFINITY;
552    }
553
554    @Override
555    public final boolean isPositive()
556    {
557        return 0 < Float.compare(this.floatValue(), 0.0F);
558    }
559
560    @Override
561    public final boolean isPositiveFinite()
562    {
563        final Float myValue = this.floatValue();
564        if (Float.isNaN(myValue)) return false;
565        if (Float.isInfinite(myValue)) return false;
566        return 0.0F < myValue;
567    }
568
569    @Override
570    public final boolean isPositiveInfinity()
571    {
572        return this.floatValue() == Float.POSITIVE_INFINITY;
573    }
574
575    @Override
576    public final boolean isReal()
577    {
578        return true;
579    }
580
581    @Override
582    public final boolean isUnity()
583    {
584        return Float.compare(this.floatValue(), 1.0F) == 0;
585    }
586
587    @Override
588    public final boolean isZero()
589    {
590        return Float.compare(this.floatValue(), 0.0F) == 0;
591    }
592
593    @Override
594    public final long longPostDecrement()
595        throws UnsupportedOperationException,
596            ArithmeticException,
597            IllegalArgumentException
598    {
599        return (long)this.floatPostDecrement();
600    }
601
602    @Override
603    public final long longPostIncrement()
604        throws UnsupportedOperationException,
605            ArithmeticException,
606            IllegalArgumentException
607    {
608        return (long)this.floatPostIncrement();
609    }
610
611    @Override
612    public final long longValue()
613    {
614        return (long)this.floatValue();
615    }
616
617    @Override
618    public final PRIMITIVE negate()
619        throws UnsupportedOperationException,
620            ArithmeticException,
621            IllegalArgumentException
622    {
623        return this.setScalar(-this.floatValue());
624    }
625
626    @Override
627    public final PRIMITIVE not()
628        throws UnsupportedOperationException,
629            IllegalArgumentException,
630            ArithmeticException
631    {
632        return this.setReal(this.toUnlimitedInteger().not());
633    }
634
635    @Override
636    public final PRIMITIVE or( final BigInteger aValue )
637        throws UnsupportedOperationException,
638            IllegalArgumentException,
639            ArithmeticException
640    {
641        return this.setReal(this.toUnlimitedInteger().or(aValue));
642    }
643
644    @Override
645    public final PRIMITIVE or( final boolean aValue )
646        throws UnsupportedOperationException,
647            IllegalArgumentException,
648            ArithmeticException
649    {
650        return this.or(Constant.toUnlimitedInteger(aValue));
651    }
652
653    @Override
654    public final PRIMITIVE or( final byte aValue )
655        throws UnsupportedOperationException,
656            IllegalArgumentException,
657            ArithmeticException
658    {
659        return this.or(BigInteger.valueOf(aValue));
660    }
661
662    @Override
663    public final PRIMITIVE or( final char aValue )
664        throws UnsupportedOperationException,
665            IllegalArgumentException,
666            ArithmeticException
667    {
668        return this.or(BigInteger.valueOf(aValue));
669    }
670
671    @Override
672    public final PRIMITIVE or( final int aValue )
673        throws UnsupportedOperationException,
674            IllegalArgumentException,
675            ArithmeticException
676    {
677        return this.or(BigInteger.valueOf(aValue));
678    }
679
680    @Override
681    public final PRIMITIVE or( final long aValue )
682        throws UnsupportedOperationException,
683            IllegalArgumentException,
684            ArithmeticException
685    {
686        return this.or(BigInteger.valueOf(aValue));
687    }
688
689    @Override
690    public final PRIMITIVE or( final short aValue )
691        throws UnsupportedOperationException,
692            IllegalArgumentException,
693            ArithmeticException
694    {
695        return this.or(BigInteger.valueOf(aValue));
696    }
697
698    @Override
699    public final PRIMITIVE product( final BigDecimal aValue )
700        throws UnsupportedOperationException,
701            IllegalArgumentException,
702            ArithmeticException
703    {
704        return this.setReal(this.toUnlimitedDecimal().multiply(aValue));
705    }
706
707    @Override
708    public final PRIMITIVE product( final BigInteger aValue )
709        throws UnsupportedOperationException,
710            IllegalArgumentException,
711            ArithmeticException
712    {
713        return this.product(Constant.toUnlimitedDecimal(aValue));
714    }
715
716    @Override
717    public final PRIMITIVE product( final boolean aValue )
718        throws UnsupportedOperationException,
719            IllegalArgumentException,
720            ArithmeticException
721    {
722        return this.product(Constant.toUnlimitedDecimal(aValue));
723    }
724
725    @Override
726    public final PRIMITIVE product( final byte aValue )
727        throws UnsupportedOperationException,
728            IllegalArgumentException,
729            ArithmeticException
730    {
731        return this.setScalar(this.floatValue() * aValue);
732    }
733
734    @Override
735    public final PRIMITIVE product( final char aValue )
736        throws UnsupportedOperationException,
737            IllegalArgumentException,
738            ArithmeticException
739    {
740        return this.setScalar(this.floatValue() * aValue);
741    }
742
743    @Override
744    public final PRIMITIVE product( final int aValue )
745        throws UnsupportedOperationException,
746            IllegalArgumentException,
747            ArithmeticException
748    {
749        return this.setScalar(this.floatValue() * aValue);
750    }
751
752    @Override
753    public final PRIMITIVE product( final long aValue )
754        throws UnsupportedOperationException,
755            IllegalArgumentException,
756            ArithmeticException
757    {
758        return this.setScalar(this.floatValue() * aValue);
759    }
760
761    @Override
762    public final PRIMITIVE product( final short aValue )
763        throws UnsupportedOperationException,
764            IllegalArgumentException,
765            ArithmeticException
766    {
767        return this.setScalar(this.floatValue() * aValue);
768    }
769
770    @Override
771    public final PRIMITIVE quotient( final BigDecimal aValue )
772        throws UnsupportedOperationException,
773            IllegalArgumentException,
774            ArithmeticException
775    {
776        return this.setReal(this.toUnlimitedDecimal().divide(aValue));
777    }
778
779    @Override
780    public final PRIMITIVE quotient( final BigInteger aValue )
781        throws UnsupportedOperationException,
782            IllegalArgumentException,
783            ArithmeticException
784    {
785        return this.quotient(Constant.toUnlimitedDecimal(aValue));
786    }
787
788    @Override
789    public final PRIMITIVE quotient( final boolean aValue )
790        throws UnsupportedOperationException,
791            IllegalArgumentException,
792            ArithmeticException
793    {
794        return this.quotient(Constant.toUnlimitedDecimal(aValue));
795    }
796
797    @Override
798    public final PRIMITIVE quotient( final byte aValue )
799        throws UnsupportedOperationException,
800            IllegalArgumentException,
801            ArithmeticException
802    {
803        return this.setScalar(this.floatValue() / aValue);
804    }
805
806    @Override
807    public final PRIMITIVE quotient( final char aValue )
808        throws UnsupportedOperationException,
809            IllegalArgumentException,
810            ArithmeticException
811    {
812        return this.setScalar(this.floatValue() / aValue);
813    }
814
815    @Override
816    public final PRIMITIVE quotient( final int aValue )
817        throws UnsupportedOperationException,
818            IllegalArgumentException,
819            ArithmeticException
820    {
821        return this.setScalar(this.floatValue() / aValue);
822    }
823
824    @Override
825    public final PRIMITIVE quotient( final long aValue )
826        throws UnsupportedOperationException,
827            IllegalArgumentException,
828            ArithmeticException
829    {
830        return this.setScalar(this.floatValue() / aValue);
831    }
832
833    @Override
834    public final PRIMITIVE quotient( final short aValue )
835        throws UnsupportedOperationException,
836            IllegalArgumentException,
837            ArithmeticException
838    {
839        return this.setScalar(this.floatValue() / aValue);
840    }
841
842    @Override
843    public final PRIMITIVE round( final RoundingStrategy aRoundingStrategy )
844        throws UnsupportedOperationException,
845            IllegalArgumentException,
846            ArithmeticException,
847            NullPointerException
848    {
849        return this.setScalar(aRoundingStrategy.floatValue(this.floatValue()));
850    }
851
852    @Override
853    public final PRIMITIVE setMaximum()
854        throws UnsupportedOperationException,
855            ArithmeticException,
856            IllegalArgumentException
857    {
858        return this.setScalar(Float.MAX_VALUE);
859    }
860
861    @Override
862    public final PRIMITIVE setMinimum()
863        throws UnsupportedOperationException,
864            ArithmeticException,
865            IllegalArgumentException
866    {
867        return this.setScalar(Float.MIN_VALUE);
868    }
869
870    @Override
871    public final PRIMITIVE setNegativeInfinity()
872        throws UnsupportedOperationException,
873            ArithmeticException,
874            IllegalArgumentException
875    {
876        return this.setScalar(Float.NEGATIVE_INFINITY);
877    }
878
879    @Override
880    public final PRIMITIVE setNumber( final Number aValue )
881        throws UnsupportedOperationException,
882            IllegalArgumentException,
883            ArithmeticException,
884            NullPointerException
885    {
886        return this.setScalar(aValue.floatValue());
887    }
888
889    @Override
890    public final PRIMITIVE setPositiveInfinity()
891        throws UnsupportedOperationException,
892            ArithmeticException,
893            IllegalArgumentException
894    {
895        return this.setScalar(Float.POSITIVE_INFINITY);
896    }
897
898    @Override
899    public final PRIMITIVE setPrimitive( final SealedPrimitive<?> aValue )
900        throws UnsupportedOperationException,
901            IllegalArgumentException,
902            ArithmeticException,
903            NullPointerException
904    {
905        return this.setScalar(aValue.floatValue());
906    }
907
908    @Override
909    public final PRIMITIVE setReal( final BigDecimal aValue )
910        throws UnsupportedOperationException,
911            IllegalArgumentException,
912            ArithmeticException,
913            NullPointerException
914    {
915        return this.setScalar(aValue.floatValue());
916    }
917
918    @Override
919    public final PRIMITIVE setReal( final BigInteger aValue )
920        throws UnsupportedOperationException,
921            IllegalArgumentException,
922            ArithmeticException,
923            NullPointerException
924    {
925        return this.setScalar(aValue.floatValue());
926    }
927
928    @Override
929    public final PRIMITIVE setReal( final SealedReal<?> aValue )
930        throws UnsupportedOperationException,
931            IllegalArgumentException,
932            ArithmeticException,
933            NullPointerException
934    {
935        return this.setScalar(aValue.floatValue());
936    }
937
938    @Override
939    public final PRIMITIVE setScalar( final boolean aValue )
940        throws UnsupportedOperationException,
941            IllegalArgumentException,
942            ArithmeticException
943    {
944        return this.setScalar(To.floatValue(aValue));
945    }
946
947    @Override
948    public final PRIMITIVE setScalar( final byte aValue )
949        throws UnsupportedOperationException,
950            IllegalArgumentException,
951            ArithmeticException
952    {
953        return this.setScalar((float)aValue);
954    }
955
956    @Override
957    public final PRIMITIVE setScalar( final char aValue )
958        throws UnsupportedOperationException,
959            IllegalArgumentException,
960            ArithmeticException
961    {
962        return this.setScalar((float)aValue);
963    }
964
965    @Override
966    public final PRIMITIVE setScalar( final double aValue )
967        throws UnsupportedOperationException,
968            IllegalArgumentException,
969            ArithmeticException
970    {
971        return this.setScalar((float)aValue);
972    }
973
974    @Override
975    public final PRIMITIVE setScalar( final int aValue )
976        throws UnsupportedOperationException,
977            IllegalArgumentException,
978            ArithmeticException
979    {
980        return this.setScalar((float)aValue);
981    }
982
983    @Override
984    public final PRIMITIVE setScalar( final long aValue )
985        throws UnsupportedOperationException,
986            IllegalArgumentException,
987            ArithmeticException
988    {
989        return this.setScalar((float)aValue);
990    }
991
992    @Override
993    public final PRIMITIVE setScalar( final SealedScalar<?> aValue )
994        throws UnsupportedOperationException,
995            IllegalArgumentException,
996            ArithmeticException,
997            NullPointerException
998    {
999        return this.setScalar(aValue.floatValue());
1000    }
1001
1002    @Override
1003    public final PRIMITIVE setScalar( final short aValue )
1004        throws UnsupportedOperationException,
1005            IllegalArgumentException,
1006            ArithmeticException
1007    {
1008        return this.setScalar((float)aValue);
1009    }
1010
1011    @Override
1012    public final PRIMITIVE setUnity()
1013        throws UnsupportedOperationException,
1014            IllegalArgumentException,
1015            ArithmeticException
1016    {
1017        return this.setScalar(1.0F);
1018    }
1019
1020    @Override
1021    public final PRIMITIVE setZero()
1022        throws UnsupportedOperationException,
1023            IllegalArgumentException,
1024            ArithmeticException
1025    {
1026        return this.setScalar(0.0F);
1027    }
1028
1029    @Override
1030    public PRIMITIVE shiftLeft( final int count )
1031        throws UnsupportedOperationException,
1032            IllegalArgumentException,
1033            ArithmeticException
1034    {
1035        int myValue = Float.floatToRawIntBits(this.floatValue());
1036        myValue <<= count;
1037        return this.setScalar(Float.intBitsToFloat(myValue));
1038    }
1039
1040    @Override
1041    public PRIMITIVE shiftRight( final int count )
1042        throws UnsupportedOperationException,
1043            IllegalArgumentException,
1044            ArithmeticException
1045    {
1046        int myValue = Float.floatToRawIntBits(this.floatValue());
1047        myValue >>= count;
1048        return this.setScalar(Float.intBitsToFloat(myValue));
1049    }
1050
1051    @Override
1052    public PRIMITIVE shiftRightExtendZero( final int count )
1053        throws UnsupportedOperationException,
1054            IllegalArgumentException,
1055            ArithmeticException
1056    {
1057        int myValue = Float.floatToRawIntBits(this.floatValue());
1058        myValue >>>= count;
1059        return this.setScalar(Float.intBitsToFloat(myValue));
1060    }
1061
1062    @Override
1063    public final short shortPostDecrement()
1064        throws UnsupportedOperationException,
1065            ArithmeticException,
1066            IllegalArgumentException
1067    {
1068        return (short)this.floatPostDecrement();
1069    }
1070
1071    @Override
1072    public final short shortPostIncrement()
1073        throws UnsupportedOperationException,
1074            ArithmeticException,
1075            IllegalArgumentException
1076    {
1077        return (short)this.floatPostIncrement();
1078    }
1079
1080    @Override
1081    public final short shortValue()
1082    {
1083        return (short)this.floatValue();
1084    }
1085
1086    @Override
1087    public final int signum()
1088    {
1089        return (int)Math.signum(this.floatValue());
1090    }
1091
1092    @Override
1093    public final PRIMITIVE square()
1094        throws UnsupportedOperationException,
1095            IllegalArgumentException,
1096            ArithmeticException
1097    {
1098        final float myValue = this.floatValue();
1099        return this.setScalar(myValue * myValue);
1100    }
1101
1102    @Override
1103    public final PRIMITIVE sum( final BigDecimal aValue )
1104        throws UnsupportedOperationException,
1105            IllegalArgumentException,
1106            ArithmeticException
1107    {
1108        return this.setReal(this.toUnlimitedDecimal().add(aValue));
1109    }
1110
1111    @Override
1112    public final PRIMITIVE sum( final BigInteger aValue )
1113        throws UnsupportedOperationException,
1114            IllegalArgumentException,
1115            ArithmeticException
1116    {
1117        return this.sum(Constant.toUnlimitedDecimal(aValue));
1118    }
1119
1120    @Override
1121    public final PRIMITIVE sum( final boolean aValue )
1122        throws UnsupportedOperationException,
1123            IllegalArgumentException,
1124            ArithmeticException
1125    {
1126        return this.sum(Constant.toUnlimitedDecimal(aValue));
1127    }
1128
1129    @Override
1130    public final PRIMITIVE sum( final byte aValue )
1131        throws UnsupportedOperationException,
1132            IllegalArgumentException,
1133            ArithmeticException
1134    {
1135        return this.setScalar(this.floatValue() + aValue);
1136    }
1137
1138    @Override
1139    public final PRIMITIVE sum( final char aValue )
1140        throws UnsupportedOperationException,
1141            IllegalArgumentException,
1142            ArithmeticException
1143    {
1144        return this.setScalar(this.floatValue() + aValue);
1145    }
1146
1147    @Override
1148    public final PRIMITIVE sum( final int aValue )
1149        throws UnsupportedOperationException,
1150            IllegalArgumentException,
1151            ArithmeticException
1152    {
1153        return this.setScalar(this.floatValue() + aValue);
1154    }
1155
1156    @Override
1157    public final PRIMITIVE sum( final long aValue )
1158        throws UnsupportedOperationException,
1159            IllegalArgumentException,
1160            ArithmeticException
1161    {
1162        return this.setScalar(this.floatValue() + aValue);
1163    }
1164
1165    @Override
1166    public final PRIMITIVE sum( final short aValue )
1167        throws UnsupportedOperationException,
1168            IllegalArgumentException,
1169            ArithmeticException
1170    {
1171        return this.setScalar(this.floatValue() + aValue);
1172    }
1173
1174    @Override
1175    public final PRIMITIVE swapPrimitives( final Primitive<?> aPrimitive )
1176    {
1177        final float myValue = this.floatValue();
1178        final float aValue = aPrimitive.floatValue();
1179        aPrimitive.setScalar(myValue);
1180        return this.setScalar(aValue);
1181    }
1182
1183    @Override
1184    public final Number toNumber()
1185    {
1186        return Float.valueOf(this.floatValue());
1187    }
1188
1189    @Override
1190    public final String toString()
1191    {
1192        return String.valueOf(this.floatValue());
1193    }
1194
1195    @Override
1196    public final BigDecimal toUnlimitedDecimal()
1197    {
1198        return new BigDecimal(this.toString());
1199    }
1200
1201    @Override
1202    public final BigInteger toUnlimitedInteger()
1203    {
1204        return this.toUnlimitedDecimal().toBigInteger();
1205    }
1206
1207    @Override
1208    public final BigDecimal unlimitedDecimalPostDecrement()
1209        throws UnsupportedOperationException,
1210            ArithmeticException,
1211            IllegalArgumentException
1212    {
1213        return Constant.toUnlimitedDecimal(this.floatPostDecrement());
1214    }
1215
1216    @Override
1217    public final BigDecimal unlimitedDecimalPostIncrement()
1218        throws UnsupportedOperationException,
1219            ArithmeticException,
1220            IllegalArgumentException
1221    {
1222        return Constant.toUnlimitedDecimal(this.floatPostIncrement());
1223    }
1224
1225    @Override
1226    public final BigInteger unlimitedIntegerPostDecrement()
1227        throws UnsupportedOperationException,
1228            ArithmeticException,
1229            IllegalArgumentException
1230    {
1231        return Constant.toUnlimitedDecimal(this.floatPostDecrement()).toBigInteger();
1232    }
1233
1234    @Override
1235    public final BigInteger unlimitedIntegerPostIncrement()
1236        throws UnsupportedOperationException,
1237            ArithmeticException,
1238            IllegalArgumentException
1239    {
1240        return Constant.toUnlimitedDecimal(this.floatPostIncrement()).toBigInteger();
1241    }
1242
1243    @Override
1244    public final PRIMITIVE xor( final BigInteger aValue )
1245        throws UnsupportedOperationException,
1246            IllegalArgumentException,
1247            ArithmeticException
1248    {
1249        return this.setReal(this.toUnlimitedInteger().xor(aValue));
1250    }
1251
1252    @Override
1253    public final PRIMITIVE xor( final boolean aValue )
1254        throws UnsupportedOperationException,
1255            IllegalArgumentException,
1256            ArithmeticException
1257    {
1258        return this.xor(Constant.toUnlimitedInteger(aValue));
1259    }
1260
1261    @Override
1262    public final PRIMITIVE xor( final byte aValue )
1263        throws UnsupportedOperationException,
1264            IllegalArgumentException,
1265            ArithmeticException
1266    {
1267        return this.xor(BigInteger.valueOf(aValue));
1268    }
1269
1270    @Override
1271    public final PRIMITIVE xor( final char aValue )
1272        throws UnsupportedOperationException,
1273            IllegalArgumentException,
1274            ArithmeticException
1275    {
1276        return this.xor(BigInteger.valueOf(aValue));
1277    }
1278
1279    @Override
1280    public final PRIMITIVE xor( final int aValue )
1281        throws UnsupportedOperationException,
1282            IllegalArgumentException,
1283            ArithmeticException
1284    {
1285        return this.xor(BigInteger.valueOf(aValue));
1286    }
1287
1288    @Override
1289    public final PRIMITIVE xor( final long aValue )
1290        throws UnsupportedOperationException,
1291            IllegalArgumentException,
1292            ArithmeticException
1293    {
1294        return this.xor(BigInteger.valueOf(aValue));
1295    }
1296
1297    @Override
1298    public final PRIMITIVE xor( final short aValue )
1299        throws UnsupportedOperationException,
1300            IllegalArgumentException,
1301            ArithmeticException
1302    {
1303        return this.xor(BigInteger.valueOf(aValue));
1304    }
1305}