Formatting functions for Brazilian currency (BRL).
Formatting functions for Brazilian currency (BRL).
(format-currency value)(format-currency value precision)Formats a number as Brazilian currency string (BRL).
Converts number to fixed decimal places, uses comma as decimal separator and dot as thousands separator (Brazilian format).
Args: value - The number to be formatted precision - Number of decimal places (default: 2)
Returns: The formatted currency string
Examples: (format-currency 1234.56) ;; => "1.234,56" (format-currency 1234.56 3) ;; => "1.234,560" (format-currency 0.5) ;; => "0,50" (format-currency 1000000.5) ;; => "1.000.000,50"
Formats a number as Brazilian currency string (BRL). Converts number to fixed decimal places, uses comma as decimal separator and dot as thousands separator (Brazilian format). Args: value - The number to be formatted precision - Number of decimal places (default: 2) Returns: The formatted currency string Examples: (format-currency 1234.56) ;; => "1.234,56" (format-currency 1234.56 3) ;; => "1.234,560" (format-currency 0.5) ;; => "0,50" (format-currency 1000000.5) ;; => "1.000.000,50"
(parse-currency value)Parses a string representing Brazilian currency format into a number.
Removes all non-digit characters and converts to decimal number, assuming the last 2 digits are decimals.
Args: value - The string value to be parsed (e.g., "R$ 1.234,56" or "1234,56")
Returns: The parsed number value (e.g., 1234.56), or nil for invalid input
Examples: (parse-currency "R$ 1.234,56") ;; => 1234.56 (parse-currency "1234,56") ;; => 1234.56 (parse-currency "R$ 0,50") ;; => 0.5 (parse-currency "") ;; => 0.0 (parse-currency "1000") ;; => 10.0
Parses a string representing Brazilian currency format into a number. Removes all non-digit characters and converts to decimal number, assuming the last 2 digits are decimals. Args: value - The string value to be parsed (e.g., "R$ 1.234,56" or "1234,56") Returns: The parsed number value (e.g., 1234.56), or nil for invalid input Examples: (parse-currency "R$ 1.234,56") ;; => 1234.56 (parse-currency "1234,56") ;; => 1234.56 (parse-currency "R$ 0,50") ;; => 0.5 (parse-currency "") ;; => 0.0 (parse-currency "1000") ;; => 10.0
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |