473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

what about unsigned and signed 8 bits number, 16 bits, etc??

Hi Pythoners,

When it is an integer number, what is the range of the integer number and long integer number??

do we have typecasting of 8bits or 16bits signed and unsigned number in python?

the python script i m working on would need to typecast the number it reads from a hardware. this number would then be typecasted according to its type before further processing. the typecasting is in form of signed 8bits and 16bits number. how do i do this in python??

any helps, please..

many thanks
sarmin

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Jul 18 '05 #1
2 4336
sarmin kho <sa********@yahoo.com> writes:
Hi Pythoners,

When it is an integer number, what is the range of the integer
number and long integer number??

do we have typecasting of 8bits or 16bits signed and unsigned number
in python?

the python script i m working on would need to typecast the number
it reads from a hardware. this number would then be typecasted
according to its type before further processing. the typecasting is
in form of signed 8bits and 16bits number. how do i do this in
python??
[...]

I did something like this in python once. I read all the hardware in
unsigned bytes then fed the resulting string into a 'struct'. Easier
for me to visualize and let the struct module workout all that byte
order cruft.
<{{{*>

Jul 18 '05 #2
sarmin kho <sa********@yahoo.com> wrote in message news:<ma*************************************@pyth on.org>...
Hi Pythoners,

When it is an integer number, what is the range of the integer number and
long integer number??

The integer number is a C long, which is often but not always a 4-byte
value:
range: -2147483648 -- 2147483647
do we have typecasting of 8bits or 16bits signed and unsigned number in
python?
Typecasting is not necessary in Python due to the unique type system.
I believe in every case you mentioned, Python will promote the number
to a simple (signed) int.
If you need to deal directly with C types or structures, there's a
module or two for doing that.
the python script i m working on would need to typecast the number it reads
from a hardware. this number would then be typecasted according to its type
before further processing. the typecasting is in form of signed 8bits and
16bits number. how do i do this in python??


Again, you may not have to worry about it, depending on your types.
But you can say int(x) to make an integer from x, long(x) to make a
long integer, str(x) for string, and float(x) for float.

You should read section 3.2 of the Language Reference,
http://docs.python.org/ref/types.html.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Peter Piper | last post by:
A Quick question if someone could help, im sure this has been asked before, but googling is getting me now where slowly. Is it possible to get an unsigned 32 bit integer field in Access. Im...
9
by: Fred Ma | last post by:
Hello, I've been trying to clear up a confusion about integer promotions during expression evaluation. I've checked the C FAQ and C++ FAQ (they are different languages, but I was hoping one...
9
by: dam_fool_2003 | last post by:
For int data type the default range starts from signed to unsigned. If we don't want negative value we can force an unsigned value. The same goes for long also. But I don't understand why we have...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
23
by: bjk of course | last post by:
hello, I've stumbled upon this in some code: n = !!x; I've ran it and 'n' is always either 0 or 1. Is '!!' an operator (what's it called?) and is it standard/portable? --
48
by: Frederick Gotham | last post by:
The "toupper" function takes an int as an argument. That's not too irrational given that a character literal is of type "int" in C. (Although why it isn't of type "char" escapes me... ) The...
4
by: techie | last post by:
I have defined a number of unsigned integer types as follows: typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedfe long long uint64; Is it...
7
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
30
by: viza | last post by:
Hi all int i= INT_MIN; unsigned int u= -i; Is u guaranteed to have the absolute value of INT_MIN? Why it might not: -i has type (int), and -INT_MIN might be more than INT_MAX.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.