Erlang/OTP Forums

Author Message

<  User Contributions  ~  decimal - A decimal-fixed-point module.

dsmith
Posted: Thu Nov 20, 2008 11:14 pm Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
A decimal linked-in driver backed by decNumber C library.

This first cut is just a thin wrapper around the decNumber library's decQuad type. This is 128 bit decimal fixed-point type. For now, the interface returns this binary representation.

Unfortunately, this binary representation is not portable across machine architectures and must be converted to a portable BCD or packed BCD before sending across the wire. I intend to change this to use a portable format for the exported interface, sacrificing performance somewhat.

Comments welcome..



decimal.tar.gz
 Description:
Decimal application.

Download
 Filename:  decimal.tar.gz
 Filesize:  508.93 KB
 Downloaded:  1524 Time(s)

View user's profile Send private message
dsmith
Posted: Thu Nov 20, 2008 11:46 pm Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
Usage:

Code:

Eshell V5.6.3  (abort with ^G)
1> decimal:start().
ok
2> A = decimal:divide("2","3").
{decimal,<<103,155,109,182,217,102,155,109,182,217,102,
           155,109,182,255,57>>}
3> decimal:to_list(A,"-5").
"0.66667"
4> 20.15 + 2.01.
22.159999999999997
5> decimal:to_list(decimal:add("20.15", "2.01")).
"22.16"
6>
View user's profile Send private message
dsmith
Posted: Mon Dec 29, 2008 2:36 am Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
This version changes the decimal type to make it portable across architectures. This is done at the expense of performance. The non-portable binary format is still available through the decimal_raw module. The "raw" format is subject to future changes.

In the next version, I plan to add a parse transform to allow compile-time expansion of expressions into decimal_raw expressions. There is some code in this package towards this, but it's not working and in no way complete. So don't expect it to do anything. Also, towards this end, I pulled in Ulf's ct_expand module.

Usage:
Code:

1> decimal:start().
ok
2> A = decimal:divide("2","3").
{decimal,'+',
         {<<6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,...>>,
          -34}}
3> decimal:to_list(A,"-5").
"0.66667"
4> 20.15 + 2.01.
22.159999999999997
5> decimal:to_list(decimal:add("20.15", "2.01")).
"22.16"
6> decimal:add("20.15", "2.01").                 
{decimal,'+',{<<2,2,1,6>>,-2}}
7> decimal:divide("20.15", "0.0").
{decimal,'+',infinity}
8>




decimal.tar.gz
 Description:

Download
 Filename:  decimal.tar.gz
 Filesize:  441.88 KB
 Downloaded:  1328 Time(s)

View user's profile Send private message
wuji
Posted: Sat Aug 18, 2012 8:06 am Reply with quote
User Joined: 10 Aug 2012 Posts: 654
incoln residents," the city's mayor said in a statement.Among those those red bottom shoes those present at the vigil were members of Lincoln's gay
*beep* community."Someone hurt someone in my family – my LGBT LGBT [h1]cheap Ralph Lauren Polo[/h1] LGBT family," one person told ABC's KLKN.Some residents fear this
be a setback for the local gay and *beep* community, community, cheap Ralph Lauren Polo community, one that that only two months prior saw local
approve a measure that would ensure fair treatment of gay gay cheap designer *beep* gay and transgendered residents in housing and job applications."Another reason
difficult to come out in Lincoln," wrote one commenter on on [h1]discount designer *beep*[/h1] on Outlinc's Facebook page, a local non-profit organization that supports
community's LGBT community."Many in our community are understandably experiencing a a Christian Louboutin Outlet a great deal of sadness, anger, and confusion," said Tyler
President of Outlinc, in a statement on the organization's homepage.Jeffrey homepage.Jeffrey [h2]cheap replica *beep*[/h2] homepage.Jeffrey Stern Murder-For-Hire Charges Dropped Murder Charges Against Houston Attorney
Stern Have Been DroppedBy KEVIN DOLAKJuly 24, 2012 — Charges Charges cheap designer *beep* Charges of soliciting murder have been dropped against prominent Houston
View user's profile Send private message
mbtshoes88
Posted: Tue Sep 18, 2012 8:38 am Reply with quote
User Joined: 18 Sep 2012 Posts: 30
Combine it with black or brown Cheap Armani Watches shoes, even white if you want to look different. Replica Armani Watches Standard blue generally means navy blue and Emporio Armani not any other paler shades of blue that will look odd. Classic Gray: Can be worn for different occasions and this will make even ladies turn their heads to notice you. Grays also look imposing Cheap Armani Shoes with different stripes and patterns classic gray suits are the hallmark of a gentleman. Cheap Georgio Armani Basic Black: The favorite suit of many well-dressed men and goes well Armani Online with a good white shirt. If you Armani Outlet can afford only one suit, Armani Suits then prefer this versatile Basis Black. As a fourth choice, you can select any of the above three with pinstripes. Cheap Armani Online Men Cheap Armani of average physical build Cheap Emporio Armani can choose either single-breasted or double-breasted Georgio Armani jackets. Double-breasted jackets are intended for slim men so that their leanness is not too visible and single-breasted jackets are meant for the stout to somewhat hide their obesity. Choose the jacket style Armani Sale that best suits your build. fmzds120823 The jackets must be of perfect fit and cause no wrinkles when you button them up. As far as possible, shoulder pads should be avoided and your tailor should guide you in Cheap Armani Suits this regard. You must now choose a trouser style although most men do not attach much Cheap Amarni EA7 importance to trousers and accept any pants that come with a jacket. When you discuss trousers, you need to worry about waist, drape, belt-loops, posterior-hugging, crotch-dangling, and whether or not you need a watch pocket. The best way to judge a pair of pants is to ask “Will I be able to wear these pants without the jacket and still look fine?” If the answer is Cheap Armani Outlet yes, then the pant is of perfect style and fit. Sometimes it is good to heed to the advice of a salesman and buy two pants for the same jacket. The idea is you can alternate pants with the jacket so they wear evenly over time. There may be occasions you may wear the pants minus Armani Shirts the jacket, it Cheap Armani Sale is always prudent to have a back-up pair.
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum