Giter VIP home page Giter VIP logo

postgresql-numeral's Introduction

postgresql-numeral

Christoph Berg [email protected]

postgresql-numeral provides numeric data types for PostgreSQL that use numerals (words instead of digits) for input and output.

Data types:

  • numeral: English numerals (one, two, three, four, ...), short scale (10⁹ = billion)
  • zahl: German numerals (eins, zwei, drei, vier, ...), long scale (10⁹ = Milliarde)
  • roman: Roman numerals (I, II, III, IV, ...)

Requires PostgreSQL >= 9.4 (currently up to 13) and Bison 3.

Build Status

Examples

# SELECT 'thirty'::numeral + 'twelve'::numeral as sum;
    sum
───────────
 forty-two

# SELECT 'siebzehn'::zahl * 'dreiundzwanzig' AS "Produkt";
         Produkt
──────────────────────────
 dreihunderteinundneunzig

# SELECT 'MCMLV'::roman + 'II'::roman * 'XXX' AS futurum;
 futurum
─────────
 MMXV

Implementation

The data types are internally binary compatible to bigint. Casts to and from bigint are defined (to bigint as implicit). The module does not implement any operators but instead reuses the existing bigint operators. Effectively, the data types behave like bigint, just with different input/output functions.

License

Copyright (C) 2017, 2020 Christoph Berg

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program 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 the GNU General Public License for more details.

postgresql-numeral's People

Contributors

debian-janitor avatar df7cb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

postgresql-numeral's Issues

Native transformations between numerals and int

Feature requests

  1. Now there is only select roman_in(to_char(generate_series(0, 10001), '99999')::cstring) transformation. What about roman_in(smallint) or roman_in(int)?

  2. If there is unicode-encoding (see some constants here) what about ↁ = 5000, ↂ = 10000, ↇ = 50000, ↈ = 100000 for input and output? Also there is less compact forms IƆƆ = 5000, CCIƆƆ = 10000, IƆƆƆ = 50000, CCCIƆƆƆ = 100000 at least for input.
    Note: unfortunately SELECT 'ↈ'::roman is incorrect now.

  3. In Unicode also there is special roman forms

U+2160 | Ⅰ 2160 | Ⅴ 2164 | Ⅹ 2169 | Ⅼ 216C | Ⅽ 216D | Ⅾ 216E | Ⅿ 216F
U+2170 | ⅰ 2170 | ⅴ 2174 | ⅹ 2179 | ⅼ 217C | ⅽ 217D | ⅾ 217E | ⅿ 217F
U+2180 | ↀ 2180 | ↁ 2181 | ↂ 2182 | Ↄ 2183 | ↅ 2185 | ↆ 2186 | ↇ 2187 | ↈ 2188

But it's incorrect input now: SELECT 'Ⅹ'::roman. What about support of this forms at least for input?

  1. Cast functions to smallint and int. There is internal numeric presentation, but no output.

Note: I comes with postgresql-numeral package from PGDG apt sever. Thanks for usefully SQL utility!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.