which is the best format specifier(data type) if i have to work with
decimal number.
also please tell me the syntax for truncating a decimal number
please reply as soon as possible 23 9800 ne**********@ya hoo.co.in said:
which is the best format specifier(data type) if i have to work with
decimal number.
There is no such thing as a "decimal number". Numbers are numbers. But
presumably you mean that you wish to display a number using decimal
notation, and your reference to a format specifier suggests that you wish
to do this using printf.
If you have an int type, use %d or %i. For short int and long int, apply
the appropriate modifiers, as listed in your C book (in K&R2 they're on
page 244). For unsigned int types, use %u rather than %d or %i.
If you wish to display a floating point type, use %f.
also please tell me the syntax for truncating a decimal number
This depends on what you mean by "truncate" and on what type of value you
wish to truncate (and particularly on whether you want the stored value to
be truncated, or merely the displayed value).
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
<rj*@see.sig.in validwrote:
>There is no such thing as a "decimal number". Numbers are numbers. But presumably you mean that you wish to display a number using decimal notation, and your reference to a format specifier suggests that you wish to do this using printf.
A tiny point. The Standard does use the term "decimal number" in the
section on strftime(). Its meaning is exactly what you wrote about
display, but I would avoid writing that there is no such thing as ....
You know that there is always an exception. ;-)
Robert W Hand said:
On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
<rj*@see.sig.in validwrote:
>>There is no such thing as a "decimal number". Numbers are numbers. But presumably you mean that you wish to display a number using decimal notation, and your reference to a format specifier suggests that you wish to do this using printf.
A tiny point. The Standard does use the term "decimal number" in the
section on strftime(). Its meaning is exactly what you wrote about
display, but I would avoid writing that there is no such thing as ....
You know that there is always an exception. ;-)
The fact that the Standard uses the term "decimal number" does not mean
there is such a thing as a decimal number. It merely means that the people
who wrote that part of the Standard think there is such a thing as a
decimal number.
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
In article <RO************ *************** ***@bt.com>,
Richard Heathfield <rj*@see.sig.in validwrote:
>Robert W Hand said:
>On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield <rj*@see.sig.i nvalidwrote:
>>>There is no such thing as a "decimal number". Numbers are numbers. But presumably you mean that you wish to display a number using decimal notation, and your reference to a format specifier suggests that you wish to do this using printf.
A tiny point. The Standard does use the term "decimal number" in the section on strftime(). Its meaning is exactly what you wrote about display, but I would avoid writing that there is no such thing as .... You know that there is always an exception. ;-)
The fact that the Standard uses the term "decimal number" does not mean there is such a thing as a decimal number. It merely means that the people who wrote that part of the Standard think there is such a thing as a decimal number.
I will leave it to my esteemed colleague, Mr. Twink, to give this post
all the respect that it deserves.
On 18 Feb 2008 at 3:22, Kenny McCormack wrote:
In article <RO************ *************** ***@bt.com>,
Richard Heathfield <rj*@see.sig.in validwrote:
>>Robert W Hand said:
>>On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield <rj*@see.sig. invalidwrote:
There is no such thing as a "decimal number". Numbers are numbers. But presumabl y you mean that you wish to display a number using decimal notation, and your reference to a format specifier suggests that you wish to do this using printf.
A tiny point. The Standard does use the term "decimal number" in the section on strftime(). Its meaning is exactly what you wrote about display, but I would avoid writing that there is no such thing as .... You know that there is always an exception. ;-)
The fact that the Standard uses the term "decimal number" does not mean there is such a thing as a decimal number. It merely means that the people who wrote that part of the Standard think there is such a thing as a decimal number.
I will leave it to my esteemed colleague, Mr. Twink, to give this post
all the respect that it deserves.
It would be nice to say something funny and cutting, but Heathfield's
post is so far off into la-la land that it's beyond the power of parody
to match the absurdity of the post itself... Still, it must be fun in a
way to be Heathfield, completely unconstrained by reality.
On Feb 16, 11:40*pm, neha_chha...@ya hoo.co.in wrote:
which is the best format specifier(data type) if i have to work with
decimal number.
The best format specifier for a decimal number depends upon how you
want
to use it. If you want to display a normal signed integer , you can
use "%d"
unsigned integer "%u".
Some times the when you print addresses using %d it will show as
negative,
but we know that addresses cant be negative. So we should use %u as
format
specifier.
As you know numbers can be signed or unsigned and the value
it can hold depends upon the type we use it. Also if you want
large values, you have to use appropriate data types and correspoding
format specifiers according to that. for eg.
int - %d
long - %ld
double - %lf
float - %f
hex -%x.
for the rest you can refer this link http://publib.boulder.ibm.com/infoce...specifiers.htm
also please tell me the syntax for truncating a decimal number
if you mean to say display after truncating a decimal number,
then you can use the format specifiers used for float.
please reply as soon as possible
Keith Thompson wrote:
... unsigned long is very
often the same size as unsigned long, but it's not guaranteed.
Is this the Schroedinger C compiler we're talking about here?
Keith Thompson said:
Richard Heathfield <rj*@see.sig.in validwrites:
>vh************@ gmail.com said:
<snip>
>>Some times the when you print addresses using %d it will show as negative,
Don't print addresses using %d. Addresses are pointer values, so use %p.
Use %p *after* converting the value to void*.
Whoops, I forgot to mention that.
<snip>
>Actually, %x takes an int, not a hex. C doesn't have a hex type.
Actually, %x takes an unsigned int.
4.9.6.1 of C89:
d, i, o, u, x, X The int argument is converted to signed decimal ( d
or i ), unsigned octal ( o ), unsigned decimal ( u ), or unsigned
hexadecimal notation ( x or X );
Sure looks like int to me.
<snip>
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:
Keith Thompson said:
>Richard Heathfield <rj*@see.sig.in validwrites:
>>Actually, %x takes an int, not a hex. C doesn't have a hex type.
Actually, %x takes an unsigned int.
4.9.6.1 of C89:
d, i, o, u, x, X The int argument is converted to signed decimal ( d
or i ), unsigned octal ( o ), unsigned decimal ( u ), or unsigned
hexadecimal notation ( x or X );
Sure looks like int to me.
Interesting. C99 7.19.6.1p8:
o,u,x,X The _unsigned int_ argument is converted to unsigned octal (o),
unsigned decimal (u), or unsigned hexadecimal notation (x or X)
in the style /dddd/; [...] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Batista, Facundo |
last post by:
Here I send it.
Suggestions and all kinds of recomendations are more than welcomed.
If it all goes ok, it'll be a PEP when I finish writing/modifying the code.
Thank you.
.. Facundo
|
by: android |
last post by:
I require a function that takes a double as a parameter and returns the number of decimal places. What is the most efficient way in c# to find out the number of decimal places
I have written a function that does it by converting the double to a string. Is there a better way
public static int CountDecimalPlaces(double double1)
return double1.ToString().Substring(double1.ToString().IndexOf(".")+1).Length
Thank yo
|
by: Zeng |
last post by:
Hello,
I have many fields in my SQL database that are of type decimal(9,3). How do
I detect a decimal value (type decimal in C#) will overflow the db column of
sql type decimal (9,3)? Is there a way to figure out the min/max constants
of decimal(9,3) to compare against in C# to make sure the new value is "in
bound"?
Thanks!
-zeng
|
by: Kevin Chambers |
last post by:
Hi there--
I'm having a heck of a time trying to create a field of data type decimal.
It seems like, according to the docs, the following two statements should
work just fine:
ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL(10,2);
ALTER TABLE Table1 ADD COLUMN Field1 DECIMAL;
Yet both run-time error 3932 "Syntax error in field definition". Using
|
by: minjie |
last post by:
When I executed the following in Access:
alter table t1 alter column c1 decimal(8,4);
I got an error message: "Syntax error in ALTER TABLE statement". I got
a similar error when I tried to add a decimal field. I know I can
define a DECIMAL data type via Access GUI interface. But isn't there a
way to do it directly with a SQL statement?
Thanks.
| |
by: jmarr02s |
last post by:
I am trying to change my Amount column Data Type from Integer to
Decimal (precision 9 digits, scale 3, that is 6 digits to the left of
decimal and 3 digits to the right of decimal.
Here is the error message I received SQL0443N Routine "SYSPROC.ALTOBJ"
I sense this is a security issue, something my DBA must resolve and
some aspect I do not have permission to do?
Thanks,
|
by: balaki |
last post by:
Hi All,
I am using VB.Net 2003 and Ms-Access 2003. I want to change the data type of fileds programmatically. I could not find any method in vb.net to do this.
i) I tried using the sql query "ALTER TABLE TableName ALTER COLUMN FieldName Number" It works for data type like 'Number', 'Memo' etc. But if I want to change to 'Long Integer' (sub type of Number), it does not work.
ii) I tried using ADOX as shown below. It shows the 'Operation...
|
by: sillyr |
last post by:
Hi - I use Access 2007. I have a two data fields that I would like to add together in a query and then have the query sum the data for the entire table. The problem is that one of the data fields has a data type of number and the other data field has a data type of text. The data filed with the text data type is a combo box with two fields on of which is a number and t he other is text. I tried to use the functions Val and Cint, but am not...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |