Formatting number with and without decimal point

This is more of a generic powerbuilder question, but can
anyone describe how to format a number so that it will show
decimal places when there are some but then show the number
as an integer (no decimal point) when there are none.
Ex. when rounded to 2 decimal places
2.75 should show as 2.75
2.50 should show as 2.5
2.00 should show as 2

Thanks
Jay
0
Jay
1/31/2008 10:47:37 PM
sybase.net.webform 1327 articles. 0 followers. Follow

0 Replies
505 Views

Similar Articles

[PageSpeed] 24

Reply:

Similar Artilces:

Format numbers in formview so that decimal points line up
How do I format the numbers in a FormView control (and presumabaly in the other databound view controls) so that the decimal points line up? I'm displaying data using asp:label controls and for formatting I've used the curly bracket format with Eval: Text='<%# Eval("ClearedBalance", "{0:n2}") %>' Although this nicely presents numbers with a decimal point and two digits after the decimal point, everything is left justified, which means the decimal points don't line up if there are a mix of numbers less than ten, over ten, over a hundred etc. I can't find a way of right justifying the...

How to Control the number of decimal points in ASP.NET ??
Hi all, I want to know how to control the nuber of decmal points in  ASP.NET. I have this calculation: 546/742 x 100 = 73.584923456 When I use FLoat data type, it gives me 8-digit number. So, how do I control the number of decimals. For example, it should give me 73.58 instead of  73.584923456. Thanks in Advance you need to use String.Format(); have look here http://blog.stevex.net/index.php/string-formatting-in-csharp/ otherwise use substring to get 2 decimal point by search "."James Wu (MIB426).NET is only way to goMCP, MCSE, MCDBA, MCSD, MCAD try: float myNumber = ...

Need to format float with no decimals or decimal point.
Is there a format for float that displays only the integer portion?  Or at the least, integer portion and decimal point but no digits to right? Eval("L_DistCalc", "{0:f}") Thank you, What about this: Eval("L_DistCalc", "{0:f0}")Limno Wow - thanks.  Is there a good reference book that has all the format forms, control structures and properties.  Everything I have has a the essentials but nothing in depth.  I know this kind of thing is simple but is sure is a lot to try and remember. Thank you,  You can sear...

How to format a percent number as decimal using string.format in VB?
Hi, I have a GridView-Control with labels which contain numbers in percentformat, which are formatted in the RowDataBound-Event, but when I try to update the GridView i get the Invalid String format Exception because the labels are in the percentage Format like -27,5% but i need this number as double-value like 0.275. How can I convert the number from percentage to number? Any idea?  Thanks in forward,  Vlad  Dim str as string = percentlabel.Text ' Get rid of percentage sign str = str.Replace("%", "") ' Check if you can convert dim dbl as ...

inserting a decimal number from.net to stored proc. with decimal parameter
I'm trying to enter large number 99999999, (8 digits) converting to decimal in .NET, then using that as a parameter in stored proc. which has a decimal type (decimal(15,2) as a parameter. C#:if (txtAnnualizedSaving.Text.Trim() != string.Empty) {try { sdata.AnnualizedSaving = Convert.ToDecimal(txtAnnualizedSaving.Text); // only for testing ....scale = (System.Decimal.GetBits(sdata.AnnualizedSaving)[3] >> 16) & 31; }catch { sdata.AnnualizedSaving = 0; } }   ... In the business object I have the following code:private bool UpdateData() {bool ret = false; try ...

VB.NET: How to convert hexadecimal number to normal (decimal) number?
Hi to all VB.NET function Hex() converts numbers to hexadecimal strings, is there any reverse function that converts hexadecimals back to numbers?? Thanks, Hooker Hi, how are you? In C#, we have something like: Convert.ToInt32(string strValue, int Base)... So I basically can do: Int iDecimal = Convert.ToInt32("AF8", 16); I'm pretty sure there must be something like it on VB.Net. Hope this Helps, Covohttp://covodev.blogspot.com/"Everything should be made as simple as possible, but not simpler", A. Einstein That should work, thanks. I'm fine, BTW...

How to validate a decimal value with 2 digits after decimal point (de decimal point is a comma)
  I am a newbee, I have a Textbox where de user must write the price of an object. How can I validate de data entry in the Textbox (it must be a valid decimal with 2 digits after decimal point), and my pages are in  Portuguese so the decimal point to be accepted must be a comma   thanks  well you can do something like followig:  suppose TextBox1.Text = 123456,789 then you can say if(TextBox1.Text.Contains(",") ) {     int index1 = TextBox1.Text.IndexOf(",") +1;     int index2 = TextBox1.Text.IndexOf(...

format a decimal number
Hi, How do i specify a decimal number to take only two numbers after the "."? for example:if i have this number in a lable 23.222342114, how do i write my cobe to be displayed only like this 23.22 ?? thanks, use  thenumber.ToString("0.00");...

How to format a string of percentage format to decimal format ?
How to format a string of percentage format to decimal format ? 1    orginalValue  // value will be 1265.48 2    percentString // value after applying percentage format will be 126548 %3    requiredvalue // value should be 1265.48  I converted the string from orginalValue to percentString, now i need to convert back to requiredvalue. Is there any way to do ? regards, Ananth RM - msarm.com  string percentString="126548 %";double value=double.Parse(percentString.Replace("%","").Tri...

Adding Numbers with decimal points
I have been trying to add a group of textboxes together and display as a whole number with two decimal space  ...  ie 1458.35. I have been converting the textbox.text string to an integer and adding the results with a Math.Round function but it doesn't work (see below). I used the exact same code on a major project two years ago and it worked fine. I am using the (ByVal d As Decimal, decimal As Integer) As Decimal function  The code is: <  Dim num as Integer num = Textbox1.Text Dim num2 As Integer num2 = Textbox2.Text Dim num3 as Integer num3 = ...

Edit format; decimal points
In our PB application we do have a lot of datawindows with quantity fields. Most of the times (99%) the users have to enter whole numbers only but sometimes they want to enter decimal values. In the database I have a decimal field 8.2. but I am struggeling to get a right Edit mask. I like to have the following: Value of the field Display 2.00 2 2.10 2.10 (or 2.1) 2.25 2.25 Empty Nothing The problem is that when I use the format ##,###.## the decimal...

Supress Decimal Point in format
PowerBuilder 8.0.4 Build 10501 How can i get the following 12.43 1 1.5 13 i.e only show decimal places and the dp, if the item is not an integer. if i use the format #,##0.## i get : 12.43 1. 1.5 13. Which is close, but still shows the "." for integers. I did manages to get it working using a formula within a dw format field if(abs(x) <> x,"#,##0.00","#,##0") - but this really slowed down the report + i would also like to use the format in the script string function : string(12.5,'#,##0.##...

Number/Decimal Formatting Question
"0:#,###.00}"only works when the number is > 1000For Example...0 -> 0999 -> 9991001 -> 1,001.00 Is this a bug?  Or is there another way to do it?Thanks! That is just one of the options try the link below for the whole chart.  Hope this helps.http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomnumericformatstringsoutputexample.aspKind regards,Gift Peddie Are you telling me that I have to actually do an if-then statement to handle numbers >=1000 and rasmasyean:Are you telling me that I have to actually do an if-th...

Web resources about - Formatting number with and without decimal point - sybase.net.webform

Wikipedia:Manual of Style/Text formatting - Wikipedia, the free encyclopedia
The most common use of boldface is to highlight the article title, and often synonyms, in the lead section (first paragraph). This is done for ...

Formatting « Above the Law: A Legal Web Site – News, Commentary, and Opinions on Law Firms, Lawyers ...
Above the Law: A Legal Web Site – News, Commentary, and Opinions on Law Firms, Lawyers, Law School, Law Suits, Judges and Courts

Android Studio 1.2 Reaches Beta, Adds Built-In Decompiler, Inline Debugger Variables, Smarter Formatting ...
When Android Studio v1.1 entered the Stable channel, about 6 weeks ago, the Dev Tools team gave word that v1.2 was already well underway and ...

TextExpander 2.0 Brings Rich Text Formatting, Fill-In Snippets And More
TextExpander has finally received its big 2.0 update.

WordEver HD - Text Editor with Redesigned Keyboard and MarkDown syntax & formatting highlight
Holen Sie sich „WordEver HD - Text Editor with Redesigned Keyboard and MarkDown syntax & formatting highlight“ im App Store. Sehen Sie sich Screenshots, ...

Macs are vulnerable to Thunderstrike 2 firmware malware that survives formatting
... Thursday, researchers will demonstrate that not only can Macs be remotely infected with malware, but that this malware can survive a user formatting ...

16 Tips on Blog Writing and Formatting
... again. My point is that you ought to take advice with a grain of salt. And that applies to this post as well. Writing blog posts and formatting ...

Select Text With Similar Formatting in Google Docs
Google Docs added a cool new feature that lets you select all the text with similar formatting, so you can quickly make some changes. It's like ...



Resources last updated: 1/18/2016 10:23:03 PM