Within my codebase, I have implemented a method called splitNumbers in the component.ts file. This method is responsible for splitting each given number into an array containing its integer and fractional parts:
splitNumbers() {
return this.numbers.map(number => {
let str = number.toString();
return str.split(".");
});
}
Furthermore, in the component.html file, I have included separate <span>
elements to display these individual parts without any unnecessary whitespace affecting the output:
<li *ngFor="let parts of splitNumbers()">
<span class="integer">{{ parts[0] }}</span>.<span class="fractional">{{ parts[1] }}</span>
</li>
To style the presentation, in the accompanying CSS file, I have set specific attributes for the integer part to ensure proper alignment and formatting:
.integer {
text-align: right;
width: 10em;
display: inline-block;
}
The final output showcases the formatted numbers as intended.
However, there is an observation regarding the handling of very small numbers that are displayed in scientific notation instead of expanded format, posing a limitation to this implementation.