Binary fraction to decimal
Submissions: 611   Accuracy:

21.09%

  Difficulty: Basic   Marks: 1

Given an string of binary number n. The task is to convert binary fractional n into it’s decimal equivalent.

Input: n = 110.101
Output: 6.625

Input: n = 101.1101
Output: 5.8125


Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains a string n.

Output:
For each test case in a new line print the equivalent decimal equivalent of the binary string n.

Constraints:
1<=T<=100
1<=length of s<=50

Example:
Input:

2
110.101
101.1101
Output:
6.625
5.8125


 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Shubham Joshi 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.