##### Can anyone simplify this?

## Javascript

I need to shorten it but not by uglyfying it, just a better algorithm.

It's supposed to turn a binary string (e.g: "010.00101") and get the accuracy (number of signifincant digits, ie: 010.00101 => 1000101 = 7 digits), then the exponent (ie: 010.00101 => ≈1.001 x 2^**1**), and finally if the digits after the dot end in something like 000001, i'd like to chop them off the accuracy as it's close enough.

```
value = value.toString(2);
var accuracy = value.replace(".", "").length - 1;
accuracy -= (val.match(/(1[01]*?\.[01]*?|0\.[01]*?1[01]*?)(0{4,}[01]*1)/)||[0,0 ,""])[2].length;
var exponent = val.indexOf(".") - 1;
if(!val.includes("1")){
exponent = -Infinity
}
if(val.split(".")[0]=="0" && exponent!=-Infinity){
exponent = -(val.split(".")[1].indexOf("1")-1)
}
```

Please keep it unminified!

EDIT: updated regex

EDIT: I've scrapped this algorithm but if u find answer it'll still help! (You will still get 5 cycles)

Btw, ping me for stuff like this if you ever post another question, any language. Especially for regular expressions. I'm a human compiler.

Did it even work? I wrote `untested`

. That was theoretical.

@StudentFires im closing this post. Hard work, you earned the 5 cycles.

As a *regexpert*, I can say I'm improved upon your regex: `\d*?\.\d*?0000\d*1`

.`\d*\.\d*?0000\d*1`

might work too.

I still recommend using `%`

or a function from `Math`

to remove the decimal.*Gimme an upvote, I'm desperate*

If I were you, I would see if there is a better formatted version of this. looks like some ansi escape codes...

@nt998302 because of stupid regex

Untested:

Update: try