INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Formatter for non-integral numbers"
title: "EiffelBase: library of reusable components for Eiffel. ", "Based on EiffelBase library for ISE Eiffel, ", "used with permission. "
project: "EiffelBase Library"
copyright: "(c) 1986-1997 Interactive Software Engineering Inc. ", "Modifications and extensions: ", "(c) 1997-2001 Object Tools ", "All rights reserved. Duplication and distribution prohibited", "May be used only with Visual Eiffel under terms of user ", "license "
key: format_double
cluster: eiffelbase
class FORMAT_DOUBLE
inherit

FORMAT_INTEGER
rename
make as set_defaults,
split as split_integral,
formatted as fm_formatted
export
{NONE}
fm_formatted
redefine
comma_separate,
remove_separator,
underscore_separate
end

DOUBLE_MATH
export
{NONE}
all
end
creation

make
feature -- Initialization

make (w, d: INTEGER)
require
reasonable_field: w >= 1
reasonable_decimals: d <= w
ensure
blank_fill: fill_character = ' '
show_sign_negative: show_sign_negative
no_separator: no_separator
width_set: width = w
right_justified: right_justified
leading_sign: leading_sign
decimals_set: decimals = d
decimal_point: decimal = '.'
feature -- Access

after_decimal_separate: BOOLEAN

decimals: INTEGER

zero_not_shown: BOOLEAN

decimal: CHARACTER
feature -- Status setting

point_decimal
-- Use . as the decimal point.
ensure
decimal = '.'

comma_decimal
-- Use , as the decimal point.
ensure
decimal = ','

set_decimals (d: INTEGER)
-- `d' decimals to be displayed.
require
d <= width
ensure
decimals = d

separate_after_decimal
-- Use separators after the decimal.
ensure
after_decimal_separate

no_separate_after_decimal
-- Do not use separators after the decimal.
ensure
not after_decimal_separate

underscore_separate
-- Set the separator to be underscore.
ensure
after_decimal_separate

comma_separate
-- Set the separator to be comma.
ensure
after_decimal_separate

remove_separator
-- Remove the separator.
ensure
not after_decimal_separate

show_zero
-- Show 0.5 as 0.5 .
ensure
not zero_not_shown

hide_zero
-- Show 0.5 as .5 .
ensure
zero_not_shown
feature -- Conversion

formatted (d: DOUBLE): STRING
-- Format `d'.
ensure
exists: Result /= void
correct_width: Result.count >= width
invariant

separate_all: no_separator implies not after_decimal_separate
end -- class FORMAT_DOUBLE

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES