ba-st / aconcagua Goto Github PK
View Code? Open in Web Editor NEWThis project forked from mtaborda/aconcagua
Measures as first class objects, that is, an object that encapsulates a number with its unit.
License: MIT License
This project forked from mtaborda/aconcagua
Measures as first class objects, that is, an object that encapsulates a number with its unit.
License: MIT License
Should be named initializeNameForOne:nameForMany:sign:
I'd like to add some information to the docs about modeling money. This has come up many times on the MLs of the various Smalltalk flavors, and Aconcagua has been mentioned many times. However, even after reading and re-reading, I'm still not clear how Aconcagua addresses the float problem. Namely, by way of example:
result := 0.
interval := 10.21.
10000 timesRepeat: [ result := result + interval ].
result = 102100.00000001806 "(not 102100.0)"
At first, I thought that using ScaledDecimal
might help, but there were various comments saying that Pharo's ScaledDecimal is ill-conceived and maybe FixedDecimal
would be better.
Another solution I thought of would be to convert any decimal money to dollars and cents and only convert back for display. For example:
Float>>dollars
^ (AmDollar uniqueInstance * self // 1) +
(self \\ 1 * 100) asInteger cents.
Any feedback or input would be appreciated...
I tried the following and got aMeasureBag
back, but I expected 10.21
amount := 10.21.
dollarAmt := amount // 1.
centsAmt := (amount \\ 1 * 100) asInteger.
total := (AmDollar new * dollarAmt) +
(centsAmt * AmCent new).
total / (1 * AmDollar new).
Also I tried convertTo:
but got a subclassResponsibility error...
where:
AmDollar class>>#new
^ super new
initializeBaseUnit: AmCent new
conversionFactor: 100
nameForOne: 'dollar'
nameForMany: 'dollars'
sign: 'USD'
and
AmCent class>>#new
^ super new
initializeNameFomOne: 'cent'
nameForMany: 'cents'
sign: 'c USD'
It's been used in Chalten but not it Aconcagua. The implementation seems coupled with measures, maybe there is room for enhancement.
Evaluation and its subclasses doesn't have references
See discussion on #21
Add .travis.yml and .smalltalk.ston to integrate the repository with Travis and Coveralls
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.