473,396 Members | 2,003 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,396 software developers and data experts.

Datatype of non-negative values

Hi,

Is there a datatype in python which allows no negative values? I
subtract several times something from a value and I don't want to chek
everytime if this value is still bigger or equal 0.

Thanks for help!
Dirk Hagemann
Jul 18 '05 #1
2 1907
What exactly do you want to happen when result
would be negative? I'll guess be zero:

pseudocode:

x=value
x=max(x-something, 0)

That way if it goes negative, it sticks to zero.

Larry Bates
Dirk Hagemann wrote:
Hi,

Is there a datatype in python which allows no negative values? I
subtract several times something from a value and I don't want to chek
everytime if this value is still bigger or equal 0.

Thanks for help!
Dirk Hagemann

Jul 18 '05 #2
A result smaller than 0 should be just invalid.

I'd like to work with "try" and "except" like this:
value=20
try:
value=value-23
except:
print 'value is smaller than 23'

Now it should run into the "except".

Dirk Hagemann
Larry Bates <lb****@syscononline.com> wrote in message news:<0q********************@comcast.com>...
What exactly do you want to happen when result
would be negative? I'll guess be zero:

pseudocode:

x=value
x=max(x-something, 0)

That way if it goes negative, it sticks to zero.

Larry Bates
Dirk Hagemann wrote:
Hi,

Is there a datatype in python which allows no negative values? I
subtract several times something from a value and I don't want to chek
everytime if this value is still bigger or equal 0.

Thanks for help!
Dirk Hagemann

Jul 18 '05 #3

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

Similar topics

14
by: Sanjay Minni | last post by:
What is the datatype to be used for Primary Key columns for most optimised access given that - There will be a single column primary key only - The values will only be integers (but as...
5
by: Amit | last post by:
I am facing a problem while using SQL Server with VB application. Implicit conversion from datatype text to nvarchar is not allowed. Use the convert function to run this query. When i see the...
8
by: Eternally | last post by:
Hi folks, I've got a program which has a function which uses templates to accept parameters of any type. Works well, but there's one certain datatype which I want to special case and do an...
0
by: SoYouKnowBrig | last post by:
Hi All, I am using Microsoft.ApplicationBlocks.Cache.CacheManager to persist a System.Data.Dataset object. This Dataset object has a DataTable that is created from an existing DataTable using...
9
by: sandorf | last post by:
When I write: int a; and I want another name for "int", I can simply write typedef int interger but what if I want a more descriptive name for the datatype int a; ? typedef int two_intergers...
14
by: Elias Farah | last post by:
Hi All, What are people's experience in timing Query Performance? I have tried in vain, but get many unpredictable results, with execution proceeding in the background and problems of timing...
4
by: romy | last post by:
Hi I'm about to write a DLL that has to recieve and XML document as one of its parameters. However , I'm not sure that the consumers of this DLL will work under the ..NET framework, (such as...
3
by: Sri | last post by:
In VB, to know the field type of a column stored in a recordset the command I use is If rsQuery.Fields(k).Type = adCurrency Then How will I achieve the same in ASP.net. I could not find a...
4
by: Orchid | last post by:
How can I change a Date datatype to a Number datatype? For example, I want a date 10/31/2006 to show 1031 as Number datatype. But I don't want it becomes 39021. What formula should I use? ...
11
by: BD | last post by:
Hi, all. I'm running 8.2 on Windows. This is a development platform for a project whose production environment is running on a mainframe. I believe that the RI compilation process is not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
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,...
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
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.