Hey all, I have an app, that could take two numbers of any type of
numerical type int, long, double, float, uint, ulong, etc. I want to
check that the numbers are part of a range that I consider "valid".
For my circumstances, I don't consider float.PositiveI nfinity valid,
nor do I consider the two numbers valid if the second number is smaller
than the first. In other words, I want to check that the range is
valid.
I notice that while float and double have PositiveInfinit y int does
not. Does int have no comparable concept? They obviously have
MaxValue and MinValue, but I'm looking for a concept similar to
positive or negative infinity.
In summary, I just want to make my valid range check code as robust and
thorough as possible.
Thanks,
Novice 1 2450
<il***********@ gmail.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hey all, I have an app, that could take two numbers of any type of
numerical type int, long, double, float, uint, ulong, etc. I want to
check that the numbers are part of a range that I consider "valid".
For my circumstances, I don't consider float.PositiveI nfinity valid,
nor do I consider the two numbers valid if the second number is smaller
than the first. In other words, I want to check that the range is
valid.
I notice that while float and double have PositiveInfinit y int does
not. Does int have no comparable concept? They obviously have
MaxValue and MinValue, but I'm looking for a concept similar to
positive or negative infinity.
In summary, I just want to make my valid range check code as robust and
thorough as possible.
MinValue and MaxValue are as close as you can get for Int (or any
non-floating point type). These types simply have no concept of infinity -
all possible bit patterns of their representations correspond to valid
integers within their domain.
-cd This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ron Holmes |
last post by:
I posted this question on the Crystal Reports Support site and I am still
waiting for an answer.
Using Crystal Reports 9.0 Developer Full edition:
My Crystal report .RPT file has a Picture box which is an OLE Object located
in the Page Header section of my .RPT file.
This is the call which works perfectly in VB6 to format the crystal reports
Page Header section of my report file EquipLst.rpt.
|
by: hjbortol |
last post by:
Hi!
Is the expression "a >= b" equivalent to "a - b >= 0" in C/C++?
Is this equivalence an IEEE/ANSI rule? Or is this machine/compiler
dependent?
Any references are welcome!
Thanks in advance, Humberto.
|
by: napi |
last post by:
I think you would agree with me that a C compiler that directly
produces Java Byte Code to be run on any JVM is something that is
missing to software programmers so far. With such a tool one could
stay with C and still be able to produce Java byte code for
platform independent apps. Also, old programs (with some tweaking)
could be re-compiled and ported to the JVM.
We have been developing such a tool over the last 2 years and currently...
|
by: JimM |
last post by:
I am trying to create a method in VS 2003 that validates an object argument
is of the proper type and within a range of values.
I am trying to use a Type to define the casting and object type for the
validation. But I get and error of "The type or namespace name 't' could not
be found (are you missing a using directive or and assembly reference?) on
the "is" operator and the casting operation.
An example of the method follows. The...
|
by: ASP Developer |
last post by:
For some reason when I direct my users to a word document via
Response.ContentType = "application/word" the spell check is turned off.
Does anyone know which smart tag needs to be mofied to have it on by default.
It appears as though it might be <w:SpellingState>Clean</w:SpellingState>.
However, I haven't found any web sites that discusses what alternative values
of this tag might will accept. Any help would be greatly appreciated.
| |
by: Manuel |
last post by:
I think I can't find this on google/books because is soooooooo basic...
This function assign a listner pointer to an image widget:
------------------------------------------------------
void image::setListener(AbstractListener *listener)
{
this->listener = listener;
}
------------------------------------------------------
|
by: Mike Duffy |
last post by:
I just recently realized that the comparison operator "is" actually
works for comparing numeric values. Now, I know that its intended use
is for testing object identity, but I have used it for a few other
things, such as type checking, and I was just wondering whether or not
it is considered bad practice in the Python Community to use it for
numerics as well.
Example:
a = range(5)
|
by: =?Utf-8?B?Sm9hY2hpbQ==?= |
last post by:
I have an image which I'm trying to save using
my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);
and then I get the error "Parameter is not valid".
What could be the reason for this error? I know I can store it as a Png file.
|
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= |
last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm
receiving a "Specified cast is not valid" error that has something to do w/
the keys involved. The stack trace is:
======================
Message: Specified cast is not valid.
Type: System.InvalidCastException
Source: System.Data.Linq
TargetSite: Boolean TryCreateKeyFromValues(System.Object, V ByRef)
|
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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |