1
0

Currency conversions

This commit is contained in:
Scott E. Graves
2017-02-04 15:40:12 -06:00
parent 43b301f0bc
commit 5ffe77e6cd
35 changed files with 25814 additions and 38 deletions

View File

@@ -3,11 +3,10 @@
#include <cstdint>
#include <memory>
#include "json.hpp"
#include <ttmath/ttmath.h>
using json = nlohmann::json;
#define String std::wstring
#define NS_BEGIN(n) namespace n {
#define NS_END1() }
@@ -18,6 +17,11 @@ using json = nlohmann::json;
#define NS_END(c) NS_END##c()
NS_BEGIN(Sia)
NS_BEGIN(Api)
#define String std::wstring
#define Property(type, name, get_access, set_access) \
private:\
type _##name;\
@@ -41,4 +45,27 @@ struct SiaHostConfig
#define API_SUCCESS(t, x) (x == t::Success)
#define DEFAULT_CONFIG_FILE_PATH L".\\Config\\SiaDriveConfig.json"
#define DEFAULT_CONFIG_FILE_PATH L".\\Config\\SiaDriveConfig.json"
typedef ttmath::Big<1, 30> SiaCurrency;
/*
BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
BigNumber.config({ DECIMAL_PLACES: 30 })
const hastingsPerSiacoin = new BigNumber('10').toPower(24)
const siacoinsToHastings = (siacoins) => new BigNumber(siacoins).times(hastingsPerSiacoin)
const hastingsToSiacoins = (hastings) => new BigNumber(hastings).dividedBy(hastingsPerSiacoin)
*/
static inline SiaCurrency HastingsStringToSiaCurrency(const String& value)
{
ttmath::Parser<SiaCurrency> parser;
parser.Parse(value + L" / (10^24)");
return parser.stack[0].value;
}
static inline String SiaCurrencyToString(const SiaCurrency& value)
{
return value.ToWString();
}
NS_END(2)