Repository navigation
Modern String MoneyCompose
Paul Squires edited this page Oct 14, 2026
·
3 revisions
Home › String Library › String Library › MoneyCompose
The layout primitive MoneyFormat composes with: given the number, the symbol and the sign as text, it assembles them per the POSIX (precedes, sepBySpace, signPosn) model. Matches strfmon(3) cell for cell.
MoneyCompose( num, sym, signStr, precedes, sepBySpace, signPosn ) as ustring-
signPosn: 0 parentheses, 1 sign before all, 2 sign after all, 3 sign immediately before the symbol, 4 sign immediately after it. Anything out of range is treated as 1. -
sepBySpaceis 0/1/2 and not a boolean. 1 puts a space beside the number on the symbol's side; 2 puts one between the sign and the symbol. Two of the sixteen Windows negative layouts need the 2, and flattened to true/false they render$- 1.1and1.1 -$, both wrong. - The thirty combinations were GENERATED from glibc -- thirty synthetic locales built with
localedefand formatted withstrfmon(3)-- not transcribed from a description of POSIX, whose paraphrases disagree aboutsepBySpace = 2. - It reproduces one glibc wart: with
sepBySpace = 2the space is emitted even when the sign string is empty, leaving a stray leading or trailing space. MoneyFormat itself does not, because it emits no separator with nothing on one side of it.
print MoneyCompose( "1,234.50", "$", "-", true, 0, 1 ) '' -$1,234.50
print MoneyCompose( "1,234.50", "$", "-", true, 0, 4 ) '' $-1,234.50
print MoneyCompose( "1,234.50", "$", "-", true, 1, 4 ) '' $- 1,234.50
print MoneyCompose( "1,234.50", "$", "-", true, 2, 4 ) '' $ -1,234.50
print MoneyCompose( "1,234.50", "$", "", true, 0, 0 ) '' ($1,234.50)
print MoneyCompose( "1,234.50", "$", "-", false, 1, 3 ) '' 1,234.50 -$Library: String Library
Category: String Library
Documented under: Money Formatting
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing