473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Avoiding rounding in convert.tosingle method

consider ,

object a =1.123456;

float f = convert.ToSingle(a);

But when I print the value of f , I get 1.123455.

It is getting rounded off.
Also the problem is I cant change the data type of float in the code.
Please help.
Aug 24 '10 #1
1 1573
Plater
7,872 Expert 4TB
Is that outside the realm of a float/single?
You're starting with a double after all
Aug 31 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chi Tang | last post by:
Hi, I try to convert a string to a float but it alway comes out with extra value. For example, the string input is '12.6' but the output is '12.6000003814697' The following is my code to do...
3
by: Patrick De Ridder | last post by:
s is a string f is a single precision float f = float.Parse(s);// (a) f = Convert.ToSingle(s);// (b) Is (a) just as good as (b)? If one should be used, not the other, please give the reason....
2
by: Alberto | last post by:
why there isn't a Convert.ToFloat() method in the Convert class? Sometimes I can't work with a float field because there isn't this method and I need it to, for example, convert the input in a...
1
by: Mike | last post by:
Hi, I was wondering whether a difference existed between the Convert.ToString() method and the method ToString() that is sometimes available in some classes. Is one method preferred over another?...
4
by: Ken Varn | last post by:
I have an unknown numeric Type object passed into a function. I want to run a conversion on a string to convert the string to that Type object and return an object of that type. Is there some way...
3
by: sachinx | last post by:
I am calling following Powerpoint method expression.AddPlaceholder(Type, Left, Top, Width, Height) Here Left Top Width Height are optional parameters with Type as float How to call this method...
0
by: Flix | last post by:
After a bit of debugging, I discovered that the float to string conversion doesn't work as I expected. In some countries (and where I live) decimals are represented by commas, and when I pass a...
3
by: JH-PRO | last post by:
Please help! How to convert string to single Here my start values: Dim My_string as string = "29.02" Dim My_single as single = 0.0
11
by: Gary James | last post by:
I'm using an object data type variable to pass a numeric value (Int, Float, Double, etc) to a function that returns a formatted string. However, nullable types do not provide an overridden...
12
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.