Formatting number with and without decimal point

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
2/6/2008 5:26:12 PM
sybase.powerbuilder.general 62418 articles. 17 followers. Follow

5 Replies
3197 Views

Similar Articles

[PageSpeed] 28

well ... for number display formats, the # represents a number and 0 represents
a required number so ...

#.## should be what you're looking for

Jim





On 6 Feb 2008 09:26:12 -0800,
 in sybase.public.powerbuilder.general
 <Jay> wrote: 
>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
Jim
2/6/2008 7:04:21 PM
use an expression in the format:

if( col1 = truncate(col1, 0), '#,##0', '#,##0.0####')

where col1 is your column you are formatting.

this only works for FORMAT since editmask doesn't support expressions.
If you think editmasks should support expressions, then vote for it on isug.




<Jay> wrote in message news:47a9edb4.1314.1681692777@sybase.com...
> 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
M
2/6/2008 7:56:20 PM
The doc should be clearer - I just tried it and still get the trailing zeros 
in each case. # only works for leading zeros.

"Jim" <Ojr2008@aol.com> wrote in message news:47aa04b5$1@forums-1-dub...
> well ... for number display formats, the # represents a number and 0 
> represents
> a required number so ...
>
> #.## should be what you're looking for
>
> Jim
>
>
>
>
>
> On 6 Feb 2008 09:26:12 -0800,
> in sybase.public.powerbuilder.general
> <Jay> wrote:
>>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
Jerry
2/6/2008 8:04:04 PM
Jerry;

    Note that if you use a Display Format and an Edit Mask - the Edit Mask 
takes president over the Display Format. So if this is the case, make sure 
that the masks are the same.

-- 
Regards ... Chris
http://chrispollach.pbdjmagazine.com
 ,\|/,
(0 0)
-(_)-


"Jerry Siegel [TeamSybase]" <jNOsSPAMsiegel@yahoo!.com> wrote in message 
news:47aa12b4$1@forums-1-dub...
> The doc should be clearer - I just tried it and still get the trailing 
> zeros in each case. # only works for leading zeros.
>
> "Jim" <Ojr2008@aol.com> wrote in message news:47aa04b5$1@forums-1-dub...
>> well ... for number display formats, the # represents a number and 0 
>> represents
>> a required number so ...
>>
>> #.## should be what you're looking for
>>
>> Jim
>>
>>
>>
>>
>>
>> On 6 Feb 2008 09:26:12 -0800,
>> in sybase.public.powerbuilder.general
>> <Jay> wrote:
>>>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
Chris
2/7/2008 12:25:48 PM
This was on a computed field - no Edit Mask!

"Chris Pollach" <cpollach@travel-net.com> wrote in message 
news:47aaf8cc@forums-1-dub...
> Jerry;
>
>    Note that if you use a Display Format and an Edit Mask - the Edit Mask 
> takes president over the Display Format. So if this is the case, make sure 
> that the masks are the same.
>
> -- 
> Regards ... Chris
> http://chrispollach.pbdjmagazine.com
> ,\|/,
> (0 0)
> -(_)-
>
>
> "Jerry Siegel [TeamSybase]" <jNOsSPAMsiegel@yahoo!.com> wrote in message 
> news:47aa12b4$1@forums-1-dub...
>> The doc should be clearer - I just tried it and still get the trailing 
>> zeros in each case. # only works for leading zeros.
>>
>> "Jim" <Ojr2008@aol.com> wrote in message news:47aa04b5$1@forums-1-dub...
>>> well ... for number display formats, the # represents a number and 0 
>>> represents
>>> a required number so ...
>>>
>>> #.## should be what you're looking for
>>>
>>> Jim
>>>
>>>
>>>
>>>
>>>
>>> On 6 Feb 2008 09:26:12 -0800,
>>> in sybase.public.powerbuilder.general
>>> <Jay> wrote:
>>>>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
Jerry
2/7/2008 3:25:02 PM
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...

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 ...

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 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(...

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...

Comma in format of decimal numbers
Probably the silly question, but I can't seem to find it in help - if a query select price from invoice; returns value larger than a thousand, e.g. 3580.66 what sort of syntax would present that price value with a comma separating the thousand mark, i.e. 3,580.66? Cheers Try casting it as a decimal(13,2) or if you have a Money data type, use that. > Probably the silly question, but I can't seem to find it > in help - if a query > > select price from invoice; > > returns value larger than a thousand, e.g. 3580.66 > > what s...

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...

how to remove numbers after decimal point
hi, i need help , i had to do a program , but i'm stuck in this thing, the answer comes out as for example 17.79, i want to just choose 17 and ignore the rest... how can i do that , i tried many things but still :( please help .. thanx Jsut convert it to an int and it will automatically truncate the decimals.  For instance if the 17.79 is in a variable called result, just do something like this.int i = (int)result;   // in C#In VB it;s a bit more complex because explicit conversion would round, so your 17.79 would be rounded to 18. so you need to something more like this Di...

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 = ...

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...

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.##) Cheers Steve. if your trying to do this in a datawindow. try adding the following in the format expression field on the format tab of the columns property page. if( mod( INT(value_amount) , value_amount ) = 0, '##0' , '##0.##' ) > 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 woul...

Formatting numbers without leading zeros
Hello everyone. I have problems with formatting number-columns in a datawindow. I want to display the value 12.3456 as an area using the format "#,##0.00 m�". I expect it to be "12,35 m�". But it is displaid as "0.012,35 m�", that is with leading zeros. Replacing "m�" by any other string always displays the number with leading zeros. Except for signs of currencies, as dollar ($) and euro (?). Using these signs with the same format ("#,##0.00 $") displays the number as "12,35 $" (which I would prefer). Why is this so? How can I get rid of the leading zeros? Thanks. -- Rolf Knaden conject GmbH, c/o Business-Contor Philosophenweg 31-33, 47051 Duisburg Fon: +49 (0203) 9414.138 Fax: +49 (0203) 9414.555 Rolf.Knaden@conject.com www.conject.com konsequent conject. If you look in help there is only certain characters you can put in an edit mask. m=b2 is not in my help and when I use it, it doesn't work. what version are you using so that it returns: 0.012,35 m=b2 When I use that format it ruturns 0,0012.35 m=b2 If you want to display the number as then I would create a computed field and format it the way you need to. Example create a computed field: string(newrate ,"#,##0.00")+" m=b2" > Hello everyone. > > I have problems with formatting number-columns in a > datawindow. I want to display the value 12.3456 as an are...

Formatting numbers -- maximum decimal places?
Stupid number-format question here: I want to format some prices with either zero or two decimal places. 19.9000 -> $19.90 19.9900 -> $19.99 20.0000 -> $20 The only way I can think of doing this is: dim dTemp as decimal dTemp = Decimal.Round(dInput, 2) if Decimal.Truncate(dInput) = dTemp Then return "$" & Decimal.Truncate(dInput).ToString else return "$" & dTemp.ToString end if Is there a better way? have u tried somethign like: String.Format("{0:c}", dInput);Bilal Hadiar, MCP, MCTS, MCPD, M...

how to format number to 4 decimal places
I have a decimal type number in my datagrid that I want to format to 4 decimal places. I tried <asp:BoundColumn ... FormatString="{0:n}" ..../> It give me only two decimal places: 0.28 How can I format my number to display as: 0.2833 (4 decimal places)? Check out this link: http://programmers-corner.com/viewSource.php/123 Met bet is: Console.WriteLine("Number formatting to 4 decimal places: " + theDecNumber.ToString("N4")); HighOnCodingWanna get high!  Try theDecNumber.ToString("###0.0000"); http:/...

format number as a percent without rounding?
I am trying to display a number as a percentage.  From SQL, it is coming in as .99998.  So, when I do: string.Format("{0:P2}" I am getting 100.00% displayed.  I don't want it to round up to 100 - I want it to display 99.99%.  Is this possible?Thanks! One solution (with 'd' being the number 0.99998) string.Format("{0:P2}", Math.Truncate(d*10000) / 10000)JasonFA View Inside My Head...

Display number with decimal point in DW
Dear all, I like to display number with three digits after the decimal point in a DW (column object). So, in the edit tab, the editmask define as follow: Masks: Number; Mask: #####.### The numbers with decimal point it display as I like to, but numbers that there are integers (i.g-no decimal point) it display like 15. It displays '.' even for integers. How can I avoid the decimal point when I display an integer? TIA & marry Xmas to all, Thanks for the quick reply but, Even if I use the format tab the number is displayed with unnecessary zero's for example, the integer 169 will display as 169.000 (while the 169.125 will display as desired) Does anyone know how to overcome this one? TIA, At the column properties at format tab set your format to 0.000. Mask is just to format the input from the user. Good Luck. Arun "Anotoni" <amitrony@yahoo.com> wrote in message news:uQ23rlejBHA.303@forums.sybase.com... > Dear all, > I like to display number with three digits after the decimal point in a DW > (column object). > So, in the edit tab, the editmask define as follow: > Masks: Number; Mask: #####.### > The numbers with decimal point it display as I like to, but numbers that > there are integers (i.g-no decimal point) it display like 15. > It displays '.' even for integers. > How can I avoid the decimal point when I display an integer? > TIA & marry Xmas to all, &...

Windows 2000 Powerbuilder Decimal Point
The datawindow is an external datawindow. It is not linked to a database. Grtz Glenn ...

SaveAs omits the numbers after decimal point
I have encounterd a problem using datawindow.SaveAs() function to save data in dBase3 format. All numeric columns are formatted as numeric(16,0), therefore the numbers after the decimal point are lost. What can I do to get back those numbers? Please help! Thanks in advance! Ben > I have encounterd a problem using datawindow.SaveAs() function to save > data in dBase3 format. All numeric columns are formatted as > numeric(16,0), therefore the numbers after the decimal point are lost. > What can I do to get back those numbers? Please help! Is it too simplistic to sugg...

need help with formatting a decimal number
I have a field that is stored as a float in the database and I have to divide it by 3 when I display it back to the user sometimes I get this: 119.333333333333 How do I format it so it is two decimals or maybe even just drop the decimal all together? Either of these is what Im after: 119.3, 19.33, or 119. Please help. Change for your culture and number of decimal places: // Gets a NumberFormatInfo associated with the en-US culture. NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat; // Displays a negative value with th...

Formating number without leading zeros
Hello everyone. I am using PB 9.0.1 Build 7275. I have problems with formatting number-columns in a datawindow. I want to display the value 12.3456 as an area using the format "#,##0.00 m�". I expect it to be "12,35 m�". But it is displaid as "0.012,35 m�". That is, with leading zeros. Replacing "m�" by any other string always displays the number with leading zeros. Except for the euro (?) or dollar ($). Using these signs with the same format ("#,##0.00 ?") displays the number as "12,35 ?" (which I would prefer). Why is t...

What are proper format strings for String.format, Number.format, etc?
Hi guys, I just started using the client side version of the Ajax framework. Everything is working out so far, except that I can't seem to be able to format any strings of numbers the way I want. Wheather I use the String.format or Number.format functions, I just keep getting Sys.FormatException errors. What are the proper format strings? I tried the relevant ones that I use in C#, but it just doesn't work.Help would be much appreciated!  I believe D, C, N, and P are the only valid ones for numbers (client side).Encosia - ASP.NET, AJAX, and more.Latest article: Using complex ...

Number Format and String Format ?
Suppose I have a number "1", how can change the number format to "001" ? How can I convert the number "1" into string format "001" ? Thx for your help ~ :) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconnumericformatstrings.asp int x = 1;Response.Write(x.ToString("000"));Steven A SmithAspAlliance.com - The #1 ASP.NET CommunityDevAdvice.com - Answers to Questions If you got your data from SQL Stored Procedure, you can do the formating in your query: RIGHT('000' + CAST(Col1 AS varchar), 3) -- Tough People Do Tough Task -- It works ~ Thank you ve...

Web resources about - Formatting number with and without decimal point - sybase.powerbuilder.general

Disk formatting - Wikipedia, the free encyclopedia
Disk formatting is the process of preparing a data storage device such as a hard disk drive , solid-state drive , floppy disk or USB flash drive ...

Gmail for Android gets rich text formatting & one-tap RSVPs for calendar invites
Google is announcing two notable new features for Gmail for Android today, including support for rich text formatting and a new “Instant RSVPs” ...

Paper by 53 gains app extension, new text formatting tools on iOS
... Extension so you can easily send images and notes from other apps directly to Paper. The app has also been updated with some new text formatting ...

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

Gmail v5.6 Sets The Stage For Rich Text Formatting And Integration With Calendar Events [APK Teardown ...
The app updates hit quickly yesterday as about a dozen Google apps were given new versions. Among them, Gmail made an incremental bump to v5.6. ...

TextExpander 2.0 Brings Rich Text Formatting, Fill-In Snippets And More
... for Mac . One of the most notable changes brought about by TextExpander’s 2.0 update is the newly added support for rich text formatting. ...

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 ...

Productivity at your fingertips with rich text formatting and instant RSVPs
... more important than ever. That’s why today, we’re introducing two new Android features to help you manage your inbox on the go: rich text formatting ...

Resources last updated: 3/9/2016 6:47:01 AM