I've seen this issue in php and javascript. I have this number: float 0.699
if I do this:
0.699 x 100 = 69.89999999999999
why?
edit
round(0.699 x 10, 2): float 69.90000000000001
I have a counter that counts up every 1 second and add 1 to an int.
Question
How can I format my string so the counter would look like this:
00:01:23
Instead of:
123
Things I've tried
Things I've tried so far:
for (int i = 0; i < 1; i++)
{
_Counter += 1;
labelUpTime.Text = _Counter.ToString();
}
My timer's interval is set to: 1000 (so it adds 1 every second).
I did read something about string.Format(""), but I don't know if it is applicable.
Thanks if you can guide me through this :D!
I'm developing an .NET4 webapplication using MVC3.
Let's say i'm getting the following DateTime as string from an XML-feed. The xml feed is being read by my application and i'm looping through all it's descendants. The DateTime i'm receiving is begin returned in the following format (as string);
var myDateTime = "Sun Dec 19 11:45:45 +0000 2010"
I'm using the piece of code below to try and parse the DateTime string i mentioned above to a valid DateTime format (preferably dutch)
var CorrectDateTime = DateTime.ParseExact(myDateTime , "dd MMM yyyy HH:mm:ss", CultureInfo.InvariantCulture);
When trying to execute this code i'm facing an formatexception. Somebody has got any ideas?
I have a script which is reading values from an excel sheet and inserting them into an sql table. My problem is when the script reads in some of the date fields it is setting them to a default value : 1970-01-01 01:00:00
I have noticed that this is happening when it comes across a date where the 'day' is greater than 12 : 13/05/2012 18:52:33 (dd-mm-yyyy hh-mm-ss)
I thought this may be due to the script thinking that this is the month field (i.e american format) and it sees it as an invalid value, so I set the default timezone to my own hoping it may resolve the problem but it made no difference. date_default_timezone_set('Europe/Dublin');
Here is an example of what my code is doing:
Excel field value :
01/05/2012 18:32:45
Script:
$start_time = $data->val($x,5);
echo $start_time = date("Y-m-d H:i:s", strtotime($start_time));
Output:
2012-01-05 18:32:45
This is the exact format I am looking for (except for the fact that the day and month fields are switched around i.e american date format) but it doesnt work for the type of dates I mentioned above.
I am writing my first f# library
i am trying to use string.Format and it complains that no such function
Is it not available or am i doing something wrong
Time.ToString("0.0") shows up as a decimal "1.5" for instead of 1:30 how can I get it to display in a time format.
private void xTripSeventyMilesRadioButton_CheckedChanged(object sender, EventArgs e)
{
//calculation for the estimated time label
Time = Miles / SeventyMph;
this.xTripEstimateLabel.Visible = true;
this.xTripEstimateLabel.Text = "Driving at this speed the estimated travel time in hours is: " + Time.ToString("0.0") + " hrs";
}
Hi,
I have a C structure that allow users to configure options in an embedded system. Currently the GUI we use for this is custom written for every different version of this configuration structure. What I'd like for is to be able to describe the structure members in some format that can be read by the client configuration application, making it universal across all of our systems.
I've experimented with describing the structure in XML and having the client read the file; this works in most cases except those where some of the fields have inter-dependencies. So the format that I use needs to have a way to specify these; for instance, member A must always be less than or equal to half of member B.
Thanks in advance for your thoughts and suggestions.
Hi all.., I have number : 1, 2, 3, 4, 10
But I wanna print that number
0001
0002
0003
0004
0010
I have search in google, the keyword is number format. but I've got nothing, I just get, frmat decimal such ass 1,000,000.00. hope you can suggest me a reference or give me some problem solving.
Thanks,
i need a dropdownlist to show current month and year (January 2010) till January 2011, and an additional record of January 2011 +.
But I want to save this in the database as 01/01/2010 format. also if the user selects current month then the record should be getdate() to go in database, else for any other month it should be 02/01/2010 (date = 01, first day of month). how do i do this in aspx.vb .net.
i wrote a function to populate the dorpdownlist -
Public Sub Load_dates(ByRef DDL As System.Web.UI.WebControls.DropDownList)
Try
Dim i As Integer
Dim j As Integer
For i = Now.Year To Now.Year
For j = Now.Month To Now.Month + 11
DDL.Items.Add((j.ToString) + " " + (i.ToString))
Next
Next
Catch ex As Exception
ReportError(ex)
End Try
End Sub
this function only shows number like 01 2010 and 02 2010. how can i format this to show january 2010 and february 2010 and so on.
please advice
I'm seeing strange results when doing a string.Format( "C" );
E.g.
double val = 123456.78;
Console.WriteLine( val.ToString( "C" ) );
This prints the thousand separator as 0xa0 rather than a comma (0x2c).
I get the same result if I use string.Format( "{0:0,0.00}", 1234567.12D );
Here is the full output
R 123ÿ456,78
52333A333233
201230456C78
My regional settings are English (South African) and I'm getting the same result on multiple machines.
Any ideas?
Thanks.
Hi, in C if I have a printf statement containing say "%.2f", it says that the precision is 2 digits after the decimal place. I haven't explicitly specify the width. I have two questions:
Is this good programming practice?;
Is without specifying the width means that the width of the field will get adjusted automatically when printing the number, irrespective of the number of digits it contains?
Thanks a lot...
So apparently i've stumbled upon a coding error when trying to select the time from my database.
SELECT * FROM `videos` WHERE `added_time` > AddTime( CurTime(), '14400 hour' )
is the code, i'm trying to select all the videos posted 10 days (14400 hours) ago using the "added_time" format, because it worked for my previous coding but in this one it work work.
Shown below is a link to the image showing how my database structure for videos are shown.
http://i.imm.io/NURT.png
Edit: Previously i had this problem for retrieving and deleting bulletins posted 10 days ago, and this code worked, however this code apparently won't work when trying to retrieve the videos :/ I don't know why, they're using the same format.
See: http://i.imm.io/NUSW.png
How will various functions that take printf format string behave upon encountering the %c format given value of \0/NULL?
How should they behave? Is it safe? Is it defined? Is it compiler-specific?
e.g. sprintf() - will it crop the result string at the NULL? What length will it return?
Will printf() output the whole format string or just up to the new NULL?
Will va_args + vsprintf/vprintf be affected somehow? If so, how?
Do I risk memory leaks or other problems if I e.g. shoot this NULL at a point in std::string.c_str()?
What are the best ways to avoid this caveat (sanitize input?)
Are there any softwares to convert 2D videos to 3D (preferably XviD avi) so that I can watch them with 3D glasses? No matter if it's freeware or shareware.
When you use iTunes to sync your videos with the iPhone the videos are always saved with no more than 640 pixels wide, if I am not wrong.
What about the iPad? What is the size of videos iTunes syncs with iPad? 1024x768? and what if the video has a dimension below 1024x768? Will it scale up? or will it keep the video at low res and scale when you play?
thanks.
How am I supposed to pass a password to ldapsearch using the -y <password file> option?
If I write the password in the password file in plain text, I get this error:
ldap_bind: Invalid credentials (49)
additional info: 80090308: LdapErr: DSID-0C0903AA, comment: AcceptSecurityContext error, data 52e, v1772
The same happens if I use the -w <password> option.
Am I missing something?
favorite Just assembled a new machine:
MSI 880GM-E41 motherboard
500GB Samsung hard drive
AMD Athlon II X4 640 processor
4GB RAM
Windows 7 64 Bit
LITE-ON Black 4X Blu-ray reader
I boot up, start the install. When it gets to the screen to select what partition, the motherboard loses power. It doesnt make sense, I can leave it in the bios settings for a very long time and it doesnt lose power. When it does lose power, the monitor shuts down and the mouse loses power, but the power light stays on. I cannot tell if it is a harware or software problem.
Just assembled a new machine:
MSI 880GM-E41 motherboard
500GB Samsung hard drive
AMD Athlon II X4 640 processor
4GB RAM
Windows 7 64 Bit
LITE-ON Black 4X Blu-ray reader
I boot up, start the install. When it gets to the screen to select what partition, the motherboard loses power. It doesnt make sense, I can leave it in the bios settings for a very long time and it doesnt lose power. When it does lose power, the monitor shuts down and the mouse loses power, but the power light stays on. I cannot tell if it is a harware or software problem.
I am attempting to search through all the files in a directory for text matching the pattern of any arbitrary directory. The output of this I hope to use to make a list of all directories referenced in the files (this part I think I can figure out on my own).
I have looked at various regex resources and made my own expression that seems to work in the browser based tool but not with grep in the command line.
/\w+[(/\w+)]+
My understanding so far is the above expression will look for the beginning / of a directory then look for an indeterminate number of characters before looking for a repeating block of the same thing.
Any guidance would be greatly appreciated.