Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:57:45+00:00 2026-06-15T10:57:45+00:00

I have to convert a string to a float, only the normal converters don’t

  • 0

I have to convert a string to a float, only the normal converters don’t work.

fi.Resolution = float.Parse(nodeC.InnerText);
fi.Resolution = (float)nodeC.InnerText; 
fi.Resolution = Single.Parse(nodeC.InnerText);

and more of those methods don’t work.
When the nodeC.InnerText is 0.01 it returns 1,
but if nodeC.InnerText is 5.72958e-07 it returns 0,0575958
and 0.0001 also returns 1, so it isn’t that it bitshifts.

Does anyone know why this standard c# converts don’t work?

So i’m trying to write my own StringToFloat method but it fails 😛

public float StringToFloat(string input)
        {
            float output = 0;
            char[] arr = input.ToCharArray();

            for (int i = 0; i < input.Length - 1; i++)
            {
                if (arr[i].Equals("."))
                    output += 1;//change
                else
                    output += Convert.ToInt32(arr[i]);
            }

            return output;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:57:46+00:00Added an answer on June 15, 2026 at 10:57 am

    Try fi.Resolution = float.Parse(nodeC.InnerText, CultureInfo.InvariantCulture);

    It looks like your current culture is expecting , as the decimal separator and ignoring any . present.

    Hence

    0.01        =>    001     => 1
    5.72958e-07 => 572958e-07 => 0,0572958 (note it gave you a , not a .)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used following code to convert string to json and parse it. String
I have some float values I want to convert to a string, I want
I have to convert an incoming String field into a BigDecimal field that would
i have variable $lang which convert string to the selected language but i am
I have written this code to convert string in such format 0(532) 222 22
I have used this function to convert string to bits. def a2bits(chars): return bin(reduce(lambda
Can anyone please help me how to convert string to date I have 3
I have a String as follows : 1|234|4456|789 I have to convert it into
how to convert a String type to a Int i have a tuple and
I have double values which I would like to convert to String values with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.