fltnum.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-------------------------> GNU Sather - sourcefile <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute and/or modify it under the terms of the GNU Library General --
-- Public License (LGPL) as published by the Free Software Foundation; --
-- either version 2 of the license, or (at your option) any later version. --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details. --
-- The license text is also available from: Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
--------------> Please email comments to <bug-sather@gnu.org> <--------------
abstract class $FLT_FMT < $FMT
abstract class $FLT_FMT < $FMT is
-- This abstract class models a value which requires a numeric plus
-- exponent kind of format layout.
-- Version 1.1 Mar 99. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 11 Feb 99 kh Original after FMT/DESCR confusion
-- 29 Mar 99 kh Revised for V8 of text classes
fmt(
descr : FLT_DESCR,
lib : LIBCHARS
) : STR ;
-- This routine formats floating point numeric formatting types using
-- the given repertoire and encoding.
fmt(
descr : FLT_DESCR
) : STR ;
-- This routine formats floating point numeric formatting types using
-- a default repertoire and encoding.
end ; -- $FLT_FMT
abstract class $FLT_DESCR < $FIXED_DESCR
abstract class $FLT_DESCR < $FIXED_DESCR is
-- This abstract class models the layot components for formatting
-- a floating point numeric value.
-- Version 1.0 Sep 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 7 Sep 98 kh Original after Modula-2 library.
exponent_size : CARD ; -- in exponent
-- If this is zero then the natural length of the exponent will be used.
val_sign : BOOL ;
exp_sign : BOOL ;
end ; -- $FLT_DESCR
class FLT_DESCR < $FLT_DESCR
class FLT_DESCR < $FLT_DESCR is
-- This implementation class implements a floating poin number layout
-- description.
-- Version 1.0 Sep 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 7 Sep 98 kh Original after Modula-2 library.
readonly attr filler : CHAR_CODE ;
readonly attr width : CARD ; -- minimum width!
readonly attr whole_digits : CARD ; -- before decimal point
readonly attr precision : CARD ; -- after decimal point
readonly attr exponent_size : CARD ; -- in exponent
-- If any of the above three are zero then the natural length of that
-- component will be used.
readonly attr val_sign : BOOL ;
readonly attr exp_sign : BOOL ;
create(
fill : CHAR_CODE,
whole,
places,
exp : CARD,
val_force,
exp_force : BOOL
) : SAME is
-- This is the single routine in this class. It returns a newly created
-- object for use when formatting.
me : SAME := new ;
me.filler := fill ;
me.whole_digits := whole ;
me.precision := places ;
me.exponent_size := exp ;
me.val_sign := val_force ;
me.exp_sign := exp_force ;
me.width := whole + places + exponent_size ;
if places > 0 then -- decimal mark needed
me.width := me.width + 1
end ;
if exp > 0 then -- exponent mark needed
me.width := me.width + 1
end ;
if val_force then -- mandatory sign
me.width := me.width + 1
end ;
if exp_force then -- mandatory sign
me.width := me.width + 1
end ;
return me
end ;
end ; -- FLT_DESCR