Libraryless. Click here for Pure Java version (192L/2K).
srecord Percent(double percent) { static Percent fromRatio(double ratio) { ret Percent(ratio*100); } static Percent fromRatio(double x, double y) { ret fromRatio(doubleRatio(x, y); } void set(double percent) { percent = percent; } double get() { ret percent; } toString { ret renderValue(percent) + " %"; } S renderValue(double percent) { ret formatDouble(percent, 1); } S renderWithDecimals aka withDecimals(int decimals) { ret formatDouble(percent, decimals) + " %"; } S withExactDecimals(int decimals) { ret formatDoubleX(percent, decimals) + " %"; } S oneDecimal() { ret withDecimals(1); } S exactlyOneDecimal() { ret withExactDecimals(1); } static Percent ratio(double x, double y) { ret new Percent(doubleRatio(x, y)*100); } }
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035756 |
Snippet name: | Percent |
Eternal ID of this version: | #1035756/11 |
Text MD5: | 2fbe6b269f0259467e91f08067d7f515 |
Transpilation MD5: | 0419483aa351d5faf4cd21a4477673a2 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-25 15:59:47 |
Source code size: | 826 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 149 / 234 |
Version history: | 10 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |