g | x | w | all
Bytes Lang Time Link
010Vyxal240928T044450Zemanresu
021Retina 0.8.2240927T143144ZUnrelate
068Python 3.12240917T195931ZMalo
060R240917T062009ZDominic
097TIBASIC240916T225815Zabsolute
084R240916T123246Zpajonk
050JavaScript Node.js240916T115349ZFhuvi
059Python240916T010600ZSTerliak
01205AB1E240916T085006ZKevin Cr
088Python 3.12240915T010906ZDavid Ch
064Haskell240914T191515ZUnrelate
093Haskell240914T143804ZDPD-
010Jelly240914T142247ZUnrelate
085Haskell240914T131444ZDPD-
005Charcoal240914T055735ZNeil
030Retina 0.8.2240914T055131ZNeil
nanVyxal240914T043133Zlyxal

Vyxal, 10 bytes

₌⌊LḞṘE₀*øḋ

Try it Online! Uses ideas from Fhuvi's JavaScript answer.

 ⌊          # Parse the result as a float
   Ḟ        # And stringify it
₌ L         # to len(input) decimal places
     Ṙ      # Reverse the result
      E     # And cast it to float again
       ₀*   # Multiply by 10
         øḋ # And stringify as a decimal.

Retina 0.8.2, 22 21 bytes

$
.
D`\.
^
0
O$^`.\.?

Try it online!

-1 and 0.8.2 compatibility thanks to Neil!

Port of my Jelly solution. Also works in Retina 1 and ties Neil's Retina 1 solution.

$
.
D`\.

Append a ., then remove it if there already is one.

^
0

Prepend a 0.

O$^`.\.?

Group non-overlapping matches of .\.? (any one character, possibly followed by .), and concatenate them reversed.

Neil's trick to save a byte here is fiendish: using $ with an O (sort) stage makes it take a second source line as a sort key, and omitting that line defaults to an empty string, which always compares equal to itself and results in no sorting. The O$ effectively acts as Retina 1's L|"", and the ^ then reverses the non-sort.

Python 3.12, 75 68 bytes

lambda n:(r:=['']+n[::-1].split('.'))[-2]+r[-1][0]+'.'+r[-1][1:]+'0'

Try it online!

(old version 75 Bytes Try it online! )

R, 67 66 60 bytes

Edit: -5 bytes thanks to pajonk

\(x)el(intToUtf8(rev(c(y<-utf8ToInt(x),46[!46%in%y]))):1)*10

Attempt This Online!

Reverse the digits (including the decimal point) and multiply by 10.
If there isn't a decimal point, add one at the end first.


R, 84 bytes

\(x){w=match(46,d<-c(b<-c(48,utf8ToInt(x)),46));b[w-1:0]=d[w-0:1];intToUtf8(rev(b))}

Attempt This Online!

Alternative 'tinkering with the decimal point' approach, in response to pajonk's answer...

Prepend a zero, then find the dot and swap it with the previous character, and finally output the reversed string.
If there isn't a dot, add one at the end of the string before the swap.

TI-BASIC, 97 bytes

Prompt N
{0,1→L₁
NAns→L₂
LinReg(ax+b) Y₁
Equ►String(Y₁,Str1
sub(Str1,1,length(Str1)-3
If not(inString(Ans,".
Ans+".
For(I,1,length(Ans)-1
sub(Ans,2I,1)+Ans
End
sub(Ans,1,I
10expr(Ans

TI-BASIC does not have built-in methods for converting numbers to strings nor reversing strings, so that has to be done manually.

Explanation:

Prompt N                   ; Request an integer and store it in N
{0,1→L₁                    ; [1] Convert N to a string
NAns→L₂                    ;
LinReg(ax+b) Y₁            ;
Equ►String(Y₁,Str1         ;
sub(Str1,1,length(Str1)-3  ; [/1]
If not(inString(Ans,".     ; If the number does not have a decimal, append one
  Ans+".                   ;
For(I,1,length(Ans)-1      ; [2] Prepend reversed digits
  sub(Ans,2I,1             ; E.g. "123.45" ⇒ "54.32123.45"
End                        ; [/2]
sub(Ans,1,I                ; Get the reversed digits
10expr(Ans                 ; Convert the string to a number, then multiply it
                           ;   by 10

Examples:

prgmCDGF2B
N=?12.34
           432.1
prgmCDGF2B
N=?3.0
               3
prgmCDGF2B
N=?012
             2.1

Note: TI-BASIC is a tokenized language. Character count does not equal byte count.
Program size is equal to \$MEM\: byte\: count - program\: name\: length - 9\: bytes\$.

[1] http://tibasicdev.wikidot.com/number-to-string
[2] http://tibasicdev.wikidot.com/reverse-a-string

R, 89 84 bytes

\(x,z=na.omit(strtoi(y<-el(strsplit(x,"")))))z%*%.1^(match(".",y,l<-sum(1|z)+1)-2:l)

Attempt This Online!

Seems that base conversion is shorter than reversing and tinkering with the decimal point.

JavaScript (Node.js), 50 51 bytes

-1 byte thanks to l4m2's tip

String and number manipulation instead of base conversion.

n=>[...(+n).toFixed(n.length)].reverse().join``*10

Try it online!


This challenge has been surprisingly harder than initially thought, because :

Python, 61 59 bytes

lambda x:re.sub('(.)(\.|$)',r'.\1',x,1)[::-1]+'0'
import re

Attempt this online!

-2 thanks to emanresuA

Original version: Attempt This Online!

Alternative regex-based approach: replace a first occurrence of a digit followed by decimal point or line end with a dot followed by that digit, then reverse and pad with zero.

Usually JS is better at regex codegolfs (at least since you don't have to import anything), but it lacks advanced slicing, so I can't make it shorter than 60 59 bytes (ATO):

s=>[...s.replace(/(.)(\.|$)/,'.$1')].reduce((p,q)=>q+p,'0')

05AB1E, 12 bytes

þRT*I'.«¤k°/

Try it online or verify all test cases.

Explanation:

þ        # Remove a potential "." from the (implicit) input by only keeping digits
 R       # Reverse it
  T*     # Multiply by 10 to add a trailing 0
I        # Push the input again
 '.«    '# Append a trailing "."
    ¤    # Push its tail (without popping): the "."
     k   # Pop both, and push the first (0-based) index of "."
      °  # Take 10 to the power this index
/        # Divide the earlier number by this
         # (after which the result is output implicitly)

Python 3.12, 100 92 88 bytes

def f(x):*x,=*x,*{d:='.'}-{*x};t=x.index(d)-1;x[t:t+2]=d,x[t];return''.join(x)[::-1]+'0'

(Old version: Try it online!)

-8 bytes thanks to UnrelatedString: Try it online!

-4 bytes thanks to STerliakov: Try it online!

Inputs and outputs valid strings. First, checks if "." is in the string, if not it is added to the end First, converts the string to a list, adding "." to the end if it isn't already present. Then, switches the "." with whatever character is before it. Then returns the string reversed, adding a "0" to the end for cases like "2.1".

Haskell, 68 67 64 bytes

g.reverse.('0':)
g s|(a,d:h:b)<-span(>'.')s=a++h:d:b|0<1=g$'.':s

Attempt This Online!

Just prepends a leading 0, reverses the whole thing, then surgically inverts the decimal point back ahead of the ones place with a fallible pattern guard--trying again with one prepended if needed. This is done after reversing so that the pattern match can extract the ones place as the second element of the suffix containing the decimal point instead of having to use functions to extract it as the last element of the prefix before it.

Haskell, 93 bytes

f=show.fst.foldl(#)(0,0)
x#'.'=x$>1
(x,0)#y=(x/10+g y,0)
(x,n)#y=(x+g y*10^n,n+1)
g=read.pure

Try it online!

Jelly, 10 bytes

nkŻœ|¥ɗ”.Ṛ

Try it online!

This feels like it should be so much simpler than it is!

      ɗ”.     With the literal character '.' on the right:
  Ż           Prepend 0 to the input
   œ|         and append '.' if it doesn't contain a '.'.
 k   ¥        Split that after indices where
n             the original input is not equal to '.'.
         Ṛ    Reverse the partitions (which are implicitly smash-printed).

Jelly, 11 bytes

pḊi¥¦Ṛḟɗ”.0

Try it online!

Full program only (may need quotes around input; test footer replicates the needed full program behavior).

       ɗ”.     With the literal character '.' on the right:
p              Pair element(s) of the input with '.'
  i ¦          at the 1-index of '.' (or 0 if not found)
 Ḋ ¥           in the input without its first element.
     Ṛ         Reverse.
      ḟ        Filter out any non-paired '.'.
          0    Print all that and return 0.

Haskell, 85 bytes

f x|elem '.'x=g x"0"|True=g(x++".")"0"
g(x:'.':y)z=g y$x:'.':z
g(x:y)z=g y$x:z
g[]z=z

Try it online!

since 0.1^n = 10^-n we simply reverse the string, taking care of some special cases

Charcoal, 5 bytes

I⍘S·¹

Try it online! Link is to verbose version of code. Explanation:

  S      Input string
 ⍘       Interpret as base
   ·¹    Literal number `0.1`
I        Cast to string
         Implicitly print

When converting a string "from" a numeric base, Charcoal interprets the characters 0-9a-zA-Z as integers from 0 to 61 and then computes the polynomial with the given input base.

Retina 0.8.2, 30 bytes

$
.
D`\.
O$^`.

\.(.)
$1.
\.$

Try it online! Link includes test cases. Explanation:

$
.

Append a ..

D`\.

Remove it again if there was already a . in the input.

O$^`.

Reverse the input.

\.(.)
$1.

Move the . forward one digit.

\.$

Delete the . if it's now at the end of the string.

8 bytes can be saved by switching to Retina 1 since the reversal and . movement can be written using V stages:

$
.
D`\.
V`
V`\..
\.$

Try it online! Link is to test suite that converts any match of /\d+(\.\d+)?/ in the input.

Vyxal, (04.41) 144 bitsv2, (08.1) 18 bytes

\./0J2Ẏ÷$ṫ$\0∴WRIṠ\.j

Try it Online!

Bitstring:

011010001110010011101111011111010001110011101100100100011100000001110010111000000000001110000100010101011110010010000111100001010101101101010100

A silly little answer