Share
Explore

icon picker
Decimals - comma instead of a full stop

Conversion form USA format to EU format and the other way around.

How to turn the USA number into a EU Number?

the easiest answer you find in this answer from Bill. This goes very fast and is accurate.

The complicated answer you find below. It is a complex puzzle I took on for the sake of puzzling. It has limited practical value.


Nbr Formatting
0
Name
input
decimalsAlternative
i
decimals
i
mainNumber
theLength
i
leftPart
rightPart
i
output
backToUSAFomat
1
Number 1
9,456,728,100
0
9456728100
10
1258
14710
9.456.728.100
9,456,728,100.00
2
Number 2
1002.10
0.1
10
1002
4
12
14
1.002,10
1,002.10
3
Number 3
32.51
0.51
51
32
2
131
2
32,51
32.51
4
Number 4
456,728,100
0
456728100
9
1147
0369
456.728.100
456,728,100.00
5
Number 5
48.4
0.4
4
48
2
131
2
48,4
48.40
6
Number 6
123,456,789.10
0.1
10
123456789
9
1147
0369
123.456.789,10
123,456,789.10
7
Number 7
1000
0
1000
4
12
14
1.000
1,000.00
8
Number 8
800
0
800
3
11
03
800
800.00
There are no rows in this table


SwitchIf(thisRow.input.Find('.') >= 1,
thisRow.input.Slice( -(thisRow.input.Length() - thisRow.input.Find('.')))).WithName(decimals,

thisRow.input.Slice(1,thisRow.input.Find('.')).Split('').Filter(CurrentValue.IsNumber()).Join('').WithName(mainNumber,
mainNumber.Length().Remainder(3).WithName(start,
Sequence(start,mainNumber.Length(),by: 3).WithName(rightPart,
Listcombine(1,Sequence(1,rightPart.Count()-1).ForEach(rightPart.Nth(CurrentValue) +1)).WithName(leftPart,
Sequence(1,rightPart.Count()).ForEach(mainNumber.Slice(leftPart.Nth(CurrentValue),rightPart.Nth(CurrentValue))).Filter(CurrentValue.IsNumber()).Join(".").WithName(outcome,
SwitchIf(
decimals.IsBlank(),outcome,
decimals.IsNotBlank(),
Format("{1}{2}{3}",
If(mainNumber > 3,outcome,mainNumber),
Concatenate(","),
decimals),
Concatenate(mainNumber,",",decimals))

))))))

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.