14e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// Copyright (c) 2004, Hewlett-Packard Development Company, L.P. 24e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// 34e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// Permission is granted free of charge to copy, modify, use and distribute 44e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// this software provided you include the entirety of this notice in all 54e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// copies made. 64e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// 74e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// THIS SOFTWARE IS PROVIDED ON AN AS IS BASIS, WITHOUT WARRANTY OF ANY 84e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, 94e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// WARRANTIES THAT THE SUBJECT SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT 104e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// FOR A PARTICULAR PURPOSE OR NON-INFRINGING. HEWLETT-PACKARD ASSUMES 114e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// NO RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE. 124e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// SHOULD THE SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, 134e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// HEWLETT-PACKARD ASSUMES NO COST OR LIABILITY FOR ANY 144e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES 154e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY SUBJECT SOFTWARE IS 164e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 174e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// 184e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING, 194e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// WITHOUT LIMITATION, NEGLIGENCE OR STRICT LIABILITY), CONTRACT, OR 204e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// OTHERWISE, SHALL HEWLETT-PACKARD BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, 214e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER WITH RESPECT TO THE 224e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// SOFTWARE INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK 234e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// STOPPAGE, LOSS OF DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL 244e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF HEWLETT-PACKARD SHALL 254e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. 264e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY RESULTING 274e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// FROM HEWLETT-PACKARD's NEGLIGENCE TO THE EXTENT APPLICABLE 284e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE 294e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT 304e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 314e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm// 324e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm 334e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehmpackage com.hp.creals; 344e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm 354e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm/** 364e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* A scientific notation representation of an approximation to a constructive 374e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* real. 384e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* Generated by CR.toStringFloatRep. 394e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm*/ 404e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehmpublic class StringFloatRep { 414e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm StringFloatRep(int s, String m, int r, int e) { 424e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm sign = s; 434e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm mantissa = m; 444e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm radix = r; 454e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm exponent = e; 464e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm } 474e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm/** 484e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* The sign associated with this approximation. May be -1, _1, or zero. 494e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm*/ 504e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm public int sign; 514e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm/** 524e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* A string representation of the mantissa. The decimal point is implicitly 534e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* to the left of the string of digits, and is not explicitly represented. 544e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm*/ 554e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm public String mantissa; 564e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm/** 574e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* The radix of the representation. Also the base of the exponent field. 584e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm*/ 594e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm public int radix; 604e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm/** 614e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* The mantissa is scaled by radix**exponent. 624e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm*/ 634e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm public int exponent; 644e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm 654e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm/** 664e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm* Produce a textual representation including the sign and exponent. 674e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm*/ 684e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm public String toString() { 694e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm return 704e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm (sign < 0? "-" : "") + mantissa + "E" + Integer.toString(exponent) 714e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm + (radix == 10? "" : "(radix " + radix + ")"); 724e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm } 734e915016a32150fc2a755ef6e32673d9c516cc3bHans Boehm} 74