decrease decimal precision

This commit is contained in:
JW 2021-11-28 04:56:54 +01:00
parent 0f1b116593
commit 6dd3a40ebc

View File

@ -17,6 +17,7 @@ enum StorageSlots {
let storagesStr = ['s1', 's2', 's3', 's4', 's5', 's6', 's7']; let storagesStr = ['s1', 's2', 's3', 's4', 's5', 's6', 's7'];
let storagesInt = ['i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7']; let storagesInt = ['i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7'];
/** /**
* Provides access to persistent storage functionality. * Provides access to persistent storage functionality.
*/ */
@ -49,7 +50,7 @@ namespace storage {
//% blockId=storage_put_number //% blockId=storage_put_number
//% group="Put" //% group="Put"
export function putNumber(key: StorageSlots, value: number) : void { export function putNumber(key: StorageSlots, value: number) : void {
let managedValue = Math.floor(value * 1000); let managedValue = Math.floor(value * 100);
putValueInt(storagesInt[key], managedValue); putValueInt(storagesInt[key], managedValue);
} }
@ -63,7 +64,7 @@ namespace storage {
//% group="Get" //% group="Get"
export function getNumber(key: StorageSlots) : number { export function getNumber(key: StorageSlots) : number {
let value = getValueInt(storagesInt[key]); let value = getValueInt(storagesInt[key]);
return value / 1000; return value / 100;
} }
/** /**