Directory

decimal-behavior - Vaadin Add-on Directory

A decimal-behavior element that provides ceil, round, floor, format and decimalAdjustemnt methods. Decimal adjustment of a number implementation is taken from Mozilla Developer Network: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round. decimal-behavior - Vaadin Add-on Directory
**[ This description is mirrored from README.md at [github.com/Protoss78/decimal-behavior](https://github.com//Protoss78/decimal-behavior/blob/1.0.0/README.md) on 2019-05-10 ]** [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/Protoss78/decimal-behavior) # decimal-behavior A decimal-behavior element that provides ceil, round, floor, format and decimalAdjustemnt methods. Decimal adjustment of a number implementation is taken from Mozilla Developer Network: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round. API documentation and live demo can be found on the component page ## Installation Install using bower bower i decimal-behavior -S Import the behavior Inlude the behavior in your web component behaviors: [DecimalBehavior] ## Example ```html ``` ## Methods ### round(value, exp) Decimal adjustment of a number using the round method. * value: The number to be adjusted * exp: The exponent (the 10 logarithm of the adjustment base). -1 = round to 1 decimal ### floor(value, exp) Decimal adjustment of a number using the floor method. * value: The number to be adjusted * exp: The exponent (the 10 logarithm of the adjustment base). -1 = round to 1 decimal ### ceil(value, exp) Decimal adjustment of a number using the ceil method. * value: The number to be adjusted * exp: The exponent (the 10 logarithm of the adjustment base). -1 = round to 1 decimal ### formatNumber(value, decimals, type) Adjusts and formats the passed value to the specified number of decimals using the passed adjustment type. The toFixed function is used to cut off the String representation. * value: The number to be adjusted * decimals: The number of decimals (is converted into an exponent). Example 1 = 1 decimal position * type: The adjustment type: round, floor or ceil. round is set as default. ### decimalAdjust(type, value, exp) Decimal adjustment of a number. Original implementation from Mozilla Developer Network: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round * type: The adjustment type: round, floor or ceil * value: The number to be adjusted * exp: The exponent (the 10 logarithm of the adjustment base). -1 = round to 1 decimal