note
	description: "Formatter for non-integral numbers"
	library: "Free implementation of ELKS library"
	status: "See notice at end of class."
	legal: "See notice at end of class."
	names: format_double
	date: "$Date: 2016-12-05 17:39:47 +0000 (Mon, 05 Dec 2016) $"
	revision: "$Revision: 99631 $"

class interface
	FORMAT_DOUBLE

create 
	make

feature -- Initialization

	make (w, d: INTEGER_32)
		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 = '.'
			trailing_zeros_shown: trailing_zeros_shown
	
feature -- Access

	after_decimal_separate: BOOLEAN
			-- Use separators after the decimal?

	decimals: INTEGER_32
			-- Number of digits after the decimal point.

	zero_not_shown: BOOLEAN
			-- Show 0.5 as .5 or 0.5?

	trailing_zeros_shown: BOOLEAN
			-- Show 0.5000 as 0.5 or 0.5000?

	decimal: CHARACTER_8
			-- What is used for the decimal
	
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_32)
			-- 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 then
				after_decimal_separate

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

	remove_separator
			-- Remove the separator.
		ensure then
				not after_decimal_separate

	show_zero
			-- Show 0.5 as 0.5 .
		ensure
				not zero_not_shown

	show_trailing_zeros
			-- Show 0.5000 as 0.5000.
		ensure
			trailing_zeros_shown_set: trailing_zeros_shown

	hide_zero
			-- Show 0.5 as .5 .
		ensure
				zero_not_shown

	hide_trailing_zeros
			-- Show 0.5000 as 0.5, and 0.0000 as 0.0.
		ensure
			trailing_zeros_shown_set: not trailing_zeros_shown
	
feature -- Conversion

	formatted (d: REAL_64): STRING_8
			-- Format d.
		ensure
			exists: Result /= Void
			correct_length: not_justified or Result.count >= width
	
invariant
	separate_all: no_separator implies not after_decimal_separate

note
	copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		5949 Hollister Ave., Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class FORMAT_DOUBLE

Generated by ISE EiffelStudio