Created with <3 with dartpad.dev.
Created
August 2, 2023 11:15
-
-
Save Laebrye/07a806065e11a32a2e61eb7675157fbd to your computer and use it in GitHub Desktop.
jade-crest-7634
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print(integralPart(2499,2)); | |
print(fractionalPart(2499,2)); | |
} | |
String? integralPart(int? centAmount, int? fractionDigits) { | |
final cent = ((centAmount?.toString().length ?? 0) - (fractionDigits ?? 0)); | |
return centAmount?.toString().substring(0, cent >= 0 ? cent : null); | |
} | |
String? fractionalPart(int? centAmount, int? fractionDigits) { | |
final cent = ((centAmount?.toString().length ?? 0) - (fractionDigits ?? 0)); | |
return centAmount?.toString().substring(cent >= 0 ? cent : 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment