Search Results

Search found 2255 results on 91 pages for 'formatting'.

Page 4/91 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • compact Number formatting behavior in Java (automatically switch between decimal and scientific notation)

    - by kostmo
    I am looking for a way to format a floating point number dynamically in either standard decimal format or scientific notation, depending on the value of the number. For moderate magnitudes, the number should be formatted as a decimal with trailing zeros suppressed. If the floating point number is equal to an integral value, the decimal point should also be suppressed. For extreme magnitudes (very small or very large), the number should be expressed in scientific notation. Alternately stated, if the number of characters in the expression as standard decimal notation exceeds a certain threshold, switch to scientific notation. I should have control over the maximum number of digits of precision, but I don't want trailing zeros appended to express the minimum precision; all trailing zeros should be suppressed. Basically, it should optimize for compactness and readability. 2.80000 - 2.8 765.000000 - 765 0.0073943162953 - 0.00739432 (limit digits of precision—to 6 in this case) 0.0000073943162953 - 7.39432E-6 (switch to scientific notation if the magnitude is small enough—less than 1E-5 in this case) 7394316295300000 - 7.39432E+6 (switch to scientific notation if the magnitude is large enough—for example, when greater than 1E+10) 0.0000073900000000 - 7.39E-6 (strip trailing zeros from significand in scientific notation) 0.000007299998344 - 7.3E-6 (rounding from the 6-digit precision limit causes this number to have trailing zeros which are stripped) Here's what I've found so far: The .toString() method of the Number class does most of what I want, except it doesn't upconvert to integer representation when possible, and it will not express large integral magnitudes in scientific notation. Also, I'm not sure how to adjust the precision. The "%G" format string to the String.format(...) function allows me to express numbers in scientific notation with adjustable precision, but does not strip trailing zeros. I'm wondering if there's already some library function out there that meets these criteria. I guess the only stumbling block for writing this myself is having to strip the trailing zeros from the significand in scientific notation produced by %G.

    Read the article

  • changing ASP.NET tag formatting

    - by Steven
    When I drag a Label control to my document, I get the following code : <asp:Label ID="Label1" runat="server" text="Label"></asp:Label> I prefer my code to look like the following instead : <asp:Label ID="Label1" runat="server" Text="Label" /> How can I get .NET to do this by default? I looked in Tools - Options - Text Editor, where you'd expect to find it, but I couldn't find anything relevant there.

    Read the article

  • Formatting Controls in ASP.NET

    - by Brian
    I feel as though this this is a simple question, but can't find an answer anywhere. We've got an interface we're trying to move to an ASP.NET control. It currently looks like: <link rel=""stylesheet"" type=""text/css"" href=""/Layout/CaptchaLayout.css"" /> <script type=""text/javascript"" src=""../../Scripts/vcaptcha_control.js""></script> <div id="captcha_background"> <div id="captcha_loading_area"> <img id="captcha" src="#" alt="" /> </div> <div id="vcaptcha_entry_container"> <input id="captcha_answer" type="text"/> <input id="captcha_challenge" type="hidden"/> <input id="captcha_publickey" type="hidden"/> <input id="captcha_host" type="hidden"/> </div> <div id="captcha_logo_container"></div> </div> However all the examples I see of ASP.NET controls that allow for basical functionality - i.e. public class MyControl : Panel { public MyControl() { } protected override void OnInit(EventArgs e) { ScriptManager.RegisterScript( ... Google script, CSS, etc. ... ); TextBox txt = new TextBox(); txt.ID = "text1"; this.Controls.Add(txt); CustomValidator vld = new CustomValidator(); vld.ControlToValidate = "text1"; vld.ID = "validator1"; this.Controls.Add(vld); } } Don't allow for the detailed layout that we need. Any suggestions on how I can combine layout and functionality and still have a single ASP control we can drop in to pages? The ultimate goal is for users of the control to just drop in: <captcha:CaptchaControl ID="CaptchaControl1" runat="server" Server="http://localhost:51947/" /> and see the working control. Sorry for the basic nature of this one, any help is greatly appreciated.

    Read the article

  • Formatting a string in Java using class attributes

    - by Jason R. Coombs
    I have a class with an attribute and getter method: public Class MyClass { private String myValue = "foo"; public String getMyValue(); } I would like to be able to use the value of foo in a formatted string as such: String someString = "Your value is {myValue}." String result = Formatter.format(someString, new MyClass()); // result is now "Your value is foo." That is, I would like to have some function like .format above which takes a format string specifying properties on some object, and an instance with those properties, and formats the string accordingly. Is it possible to do accomplish this feat in Java?

    Read the article

  • Regex for url formatting (www.domain.tld to anchors)

    - by Kristaps
    Hi. I'm currently developing a little browser-based Twitter widget. Currently, I'm stuck with getting the URLs to work. I'm kinda newbie, when it comes to regex (I know, how to get parts of a string, but this one – tough one). So, I need a regex that would search/replace www.domain.tld -> <a href="http://www.domain.tld">http://www.domain.tld</a> With/without http://, preferably. Any advice is welcome. Thanks.

    Read the article

  • Selecting multiple columns and rows for formatting - Excel

    - by Joyce
    I have a report which I used the command subtotals. Aesthetically, I just want to make these subtotal rows (columns A to P) filled with color, be in Bold and have a surrounding border. There are hundreds of totals generated in my report. And they do not have a recurring row position. So basically in order for it to look good, I do it manually per row. Is there a faster way? Thanks!

    Read the article

  • Visual Studio Formatting -- Change Method Color

    - by Daniel
    The default appearance of a method for example, ".ToString()" is by default the color black. I want to make it a different color to stand out but I do not see any options that reference this option specifically. I remember one of former collegues showing me his VS IDE years ago and he had it setup this way but I cannot recall what he did. Does anyone have any ideas on how to do this?

    Read the article

  • ASP.net Literal or Page altering HTML string, causing formatting issues

    - by Jon
    We have a service that generates a report (using word templates and a 3rd party library), and then returns a string in HTML. While this HTML isn't great - its formatted correctly in this string. We want this HTML to show up on a page - format intact. What we currently have done is set an ASP.net Literal's text element to this string. While this works, I have noticed that it has reformatted the HTML string slightly. For the most part, it looks like it generated a bunch of new CSS classes, and a new style element in the HTML. This HTML does not exist in the string thats being returned. I could filter all of this back out, but wonder if there is a better way. I assume that the Page itself is altering something. What is the best way to display this raw HTML back to the user? I can't directly use a Response.Write(string), because this page does have a few other controls on it.

    Read the article

  • formatting the output of a sql query.

    - by randeepsp
    Hi! I am using solaris os. from solaris im logging into sql plus. my database is oracle 9i. i am spooling the output of my query into a file. i want in .csv format so that i can copy it into excel. can any1 help me out. my query is like. select name,id,location from employee;

    Read the article

  • Qt - QPushButton text formatting

    - by Narek
    I have a QPushButton and on that I have a text and and icon. I want to make the text on the button to be bold and red. Looked at other forums, googled and lost my hope. Seems there is no way to do that if the button has an icon (of course if you don't creat a new icon wich is text+former icon). Is that the only way? Anyone has a better idea?

    Read the article

  • Formatting associative array declaration

    - by Drew Stephens
    When declaring an associative array, how do you handle the indentation of the elements of the array? I've seen a number of different styles (PHP syntax, since that's what I've been in lately). This is a pretty picky and trivial thing, so move along if you're interested in more serious pursuits. 1) Indent elements one more level: $array = array( 'Foo' => 'Bar', 'Baz' => 'Qux' ); 2) Indent elements two levels: $array = array( 'Foo' => 'Bar', 'Baz' => 'Qux' ); 3) Indent elements beyond the array constructor, with closing brace aligned with the start of the constructor: $array = array( 'Foo' => 'Bar', 'Baz' => 'Qux' ); 4) Indent elements beyond the array construct, with closing brace aligned with opening brace: $array = array( 'Foo' => 'Bar', 'Baz' => 'Qux' ); Personally, I like #3—the broad indentation makes it clear that we're at a break point in the code (constructing the array), and having the closing brace floating a bit to the left of all of the array's data makes it clear that this declaration is done.

    Read the article

  • Python string formatting too slow

    - by wich
    I use the following code to log a map, it is fast when it only contains zeroes, but as soon as there is actual data in the map it becomes unbearably slow... Is there any way to do this faster? log_file = open('testfile', 'w') for i, x in ((i, start + i * interval) for i in range(length)): log_file.write('%-5d %8.3f %13g %13g %13g %13g %13g %13g\n' % (i, x, map[0][i], map[1][i], map[2][i], map[3][i], map[4][i], map[5][i]))

    Read the article

  • formatting sourcecode using jQuery

    - by Sorskoot
    Does anyone know if there's a jQuery plugin to format code, XML or HTML? I'm showing the user some code on an html page. I used google prettify to make the code look pretty, but would like some indentation and linebreaks too. any suggestions?

    Read the article

  • scanf formatting issue

    - by da_rockwilder
    I have a log file with the following format: INFO 2011-03-09 10:26:15,270 [user] message I want to parse the log file using PHP: // assume file exists and all that $handle = fopen("log_file.txt", "r"); while ($line_data = fscanf($handle, "%s %s %s [%s] %s\n")) { var_dump($line_data); } fclose($handle); When I run this code I get: [0]=> array(5) { [0]=> string(4) "INFO" [1]=> string(10) "2011-03-09" [2]=> string(12) "10:26:15,270" [3]=> string(5) "user]" [4]=> NULL } // snip It appears the closing bracket in the format string ("%s %s %s [%s] %s") is disrupting the rest of the line from getting parsed. I checked the PHP docs for scanf (as suggested by fscanf), and I didn't see anything mentioning having to escape a left bracket. Any suggestions on how to get the 4th and 5th elements to look like "user" and "message" respectively?

    Read the article

  • Formatting my String

    - by pringlesinn
    I need to write currency values like $35.40 (thirty five dollars and forty cents) and after that, i want to write some "****" so at the end it will be: thirty five dollars and forty cents********* in a maximun of 100 characters I've asked a question about something very likely but I couldn't understand the main command. String format = String.format("%%-%ds", 100); String valorPorExtenso = String.format(format, new Extenso(tituloTO.getValor()).toString()); What do I need to change on format to put *** at the end of my sentence? The way it is now it puts spaces.

    Read the article

  • Formatting data for printing automatically

    - by 0bytes
    I have a requirement to retrieve data, format it to mimic an old request format we've used for years and then send it via IP address to any of a number of printers. Gathering the data and selecting the printer is no problem. I need to format the output for the printer and I'm just not sure what's best. The requirement is that the end users not have any interaction with the print request that's generated; only the intended recipients of the request job will know of the printed (& in a future release e-mailed) request. We also a requirement for a future update that we will have to incorporate into this solution an option to change the config in the DB so that each recipient site can choose printing or e-mail notification so I expect that I'll need to keep the control in a console app or webservice. I have the data and I can send it to the printers or generate an HTML-formatted e-mail easily; I just need to format it for the autoprinting. I don't think SSRS will help because I don't know of a way to designate a printer when running a report. Thanks for all help & suggestions.

    Read the article

  • Formatting numbers by tokens with php

    - by Adam D
    I'm looking for a way to format numbers using "tokens". This needs to be conditional (for the first few leading characters). Example: <?php $styles=array('04## ### ###','0# #### ####','13# ###','1800 ### ###'); format_number(0412345678); /*should return '0412 345 678'*/ format_number(0812345678); /*should return '08 1234 5678'*/ format_number(133622); /*should return '133 622'*/ format_number(1800123456); /*should return '1800 123 456'*/ ?> Incase you haven't guessed, my use of this is to format Australian phone numbers, dependent on their 'type'. I have a PHP function that does this, but it is ~114 lines and contains a lot of repeated code. Can anyone help?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >