473,802 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Int & Fix Functions

RN1
The book I am referring to learn ASP states the following about the
Int & Fix VBScript Maths functions:

=============== =============== ===========
Both Int & Fix return the integer portion of the number but the
difference lies in handling negative numbers. Int returns the first
integer lesser than or equal to the number whereas Fix returns the
first integer greater than or equal to the number.
=============== =============== ===========

I guess using the term "integer portion" would have been more
appropriate than the term "first integer", isn't it?

Nevertheless, isn't the difference stated above wrong to some extent?
This is because the output of passing a negative number to the Int
function (assuming that the number is a decimal/floating point number
& that all the integers after the decimal point are not 0) will ALWAYS
be LESSER than the integer portion of the negative number; the output
will NEVER be EQUAL to the negative number. For e.g. both

Int(-61.0003)

&

Int(-61.9999)

will return -62 which is LESSER than the integer portion of both
-61.0003 & -61.9999; it won't return -61 which is EQUAL to the integer
portion of both the negative numbers -61.0003 & -61.9999. Of course

Int(-61.0000)

&

Int(-61)

will return -61.

Also the output of passing a negative number to the Fix function (be
it a decimal/floating point number or a whole number) will ALWAYS be
EQUAL to the integer portion of the negative number; its output will
NEVER be GREATER than the integer portion of the negative number. For
e.g.

Fix(-61.0003)

Fix(-61.9999)

Fix(-61.0000)

&

Fix(-61)

will return -61 which is EQUAL to the integer portion of the 4
negative numbers; it won't return -60 which is GREATER than the
integer portion of the 4 negative numbers.

Please correct me if I am wrong.

Thanks,

Ron
Dec 22 '07 #1
8 2981
RN1 wrote on 22 dec 2007 in microsoft.publi c.inetserver.as p.general:
The book I am referring to learn ASP states the following about the
Int & Fix VBScript Maths functions:

=============== =============== ===========
Both Int & Fix return the integer portion of the number but the
difference lies in handling negative numbers. Int returns the first
integer lesser than or equal to the number whereas Fix returns the
Must be a badly written book.

Methinks "less than" would do:

"5.2 being less than the integer 6, is even lesser than 5.3" ????????

first integer greater than or equal to the number.
=============== =============== ===========

I guess using the term "integer portion" would have been more
appropriate than the term "first integer", isn't it?
No, "integer portion", though it gives a nice feeling, is only logical if
the numeric value is described as a string.

Any non integer real number has a "first integer" on "both sides" of it's
value.

MS-scripting reference 5.6 says:

"The difference between Int and Fix is that if number is negative, Int
returns the first negative integer less than or equal to number, whereas
Fix returns the first negative integer greater than or equal to number. For
example, Int converts -8.4 to -9, and Fix converts -8.4 to -8."

=============== =============== ==========
So int() returns the first integer value "less than",

while fix() returns the firrst integer value "nearer to zero".
=============== =============== ==========
Nevertheless, isn't the difference stated above wrong to some extent?
This is because the output of passing a negative number to the Int
function (assuming that the number is a decimal/floating point number
A "decimal number" in my book is just a way [11]
of writing a number to a string,
as it could also be a written as an octal [13]
or hexadecimal [b]
or binary number [111],
or written "exponentia lly" [1.1e1] [.11e2]
or "scientific " [11e0] .

Yes, I know that a non integer number, when written decimaly, has numbers
right of the integer/fractional devision sign which are wrongly called
decimal figures.

A "floating point number" is a way of internally storing a number with
a mantissa and an exponent.

An integer can be, and with ASP-VBS is, stored as a floating point number!!

So let us say "non integer number".
& that all the integers after the decimal point
"integers after a decimal point"?
Do you mean "single figures" after ...
A integer being a numeric value.
are not 0) will ALWAYS
0) ????
be LESSER than the integer portion of the negative number; the output
.... always be LESS than ...
will NEVER be EQUAL to the negative number.
Why not?

Int(-61) is just -61
r e.g. both

Int(-61.0003)

&

Int(-61.9999)

will return -62 which is LESSER than the integer portion of both
-61.0003 & -61.9999;
LESS
it won't return -61 which is EQUAL to the integer
portion of both the negative numbers -61.0003 & -61.9999. Of course
So do not use this silly notion of "integer portion"

Int(-61.0000)

&

Int(-61)

will return -61.
Not exactly! Only in effext.

Do not mingle a numberic value as used by the computer,
with the way it is written as a litteral string in a source code.

===

What does the interpreting code with:

result = Int(-61.0000)

It first takes the litteral string -61.0000 and converts it to -61 and
[with asp-vbscript] stores that as a binary floating point coded value

Then the int() is applies to that value of -61,
returning -61.

===

What does the interpreting code with:

result = Int(-61)

It first takes the litteral string -61 and converts it to -61 and [with
asp-vbscript] stores that as a binary floating point coded value

Then the int() is applies to that value of -61,
returning -61.

===

Then this result in both cases is applied to a variable called "result" and
stored again coded as a binary floating point.

>
Also the output of passing a negative number to the Fix function (be
it a decimal/floating point number or a whole number) will ALWAYS be
EQUAL to the integer portion of the negative number; its output will
NEVER be GREATER than the integer portion of the negative number. For
e.g.

Fix(-61.0003)

Fix(-61.9999)

Fix(-61.0000)

&

Fix(-61)

will return -61 which is EQUAL to the integer portion of the 4
negative numbers; it won't return -60 which is GREATER than the
integer portion of the 4 negative numbers.

Please correct me if I am wrong.
Dear Ron, never, never again mix number values and the way they are stored
internally, with the way they are written as a string litteral [and only
then depend on the number base].

To show you that input and output string litterals
are not per definition so simple, try:

<%
Response.write fix(-int(6e3) + .5) & "<br>"
Response.write hex(-int(6e3))
%>

Can you deduct with reasoning what the outup will be?

[answer below]














-5999
FFFFE890

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 22 '07 #2
"Evertjan." "wrote":
=============== =============== ==========
So int() returns the first integer value "less than",

while fix() returns the firrst integer value "nearer to zero".
=============== =============== ==========
You left off equality.

A "decimal number" in my book is just a way [11]
of writing a number to a string,
as it could also be a written as an octal [13]
or hexadecimal [b]
or binary number [111],
or written "exponentia lly" [1.1e1] [.11e2]
or "scientific " [11e0] .
Those last two are decimal examples.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Dec 22 '07 #3
Dave Anderson wrote on 22 dec 2007 in
microsoft.publi c.inetserver.as p.general:
"Evertjan." "wrote":
>============== =============== ===========
So int() returns the first integer value "less than",

while fix() returns the first integer value "nearer to zero".
============== =============== ===========

You left off equality.
Add: "if not integer already" to both.
>
>A "decimal number" in my book is just a way [11]
of writing a number to a string,
as it could also be a written as an octal [13]
or hexadecimal [b]
or binary number [111],
or written "exponentia lly" [1.1e1] [.11e2]
or "scientific " [11e0] .

Those last two are decimal examples.
Yes.

How would you call this: 3.256
fractional?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 22 '07 #4
"Evertjan." wrote:
How would you call this: 3.256
fractional?
Rational, representing 3256/1000.

Of course, in many countries, that is just 3256, right?
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Dec 22 '07 #5
Dave Anderson wrote on 22 dec 2007 in
microsoft.publi c.inetserver.as p.general:
"Evertjan." wrote:
>How would you call this: 3.256
fractional?

Rational, representing 3256/1000.
No, we were talking about ways to display numbers.

Rational numbers are a mathematic collection.
Of course, in many countries, that is just 3256, right?
Sorry?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 22 '07 #6
"Evertjan." wrote:
>>How would you call this: 3.256
fractional?

Rational, representing 3256/1000.

No, we were talking about ways to display numbers.
Don't be obtuse.
Rational numbers are a mathematic collection.
You asked what I would call it. It's not my problem if you don't like my
answer.
>Of course, in many countries, that is just 3256, right?

Sorry?
No need to apoligize for regional differences in numeric representation.
"3.256" in one country is "3,256" in others. You have no control over that.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Dec 24 '07 #7
Dave Anderson wrote on 24 dec 2007 in
microsoft.publi c.inetserver.as p.general:
>Rational numbers are a mathematic collection.

You asked what I would call it. It's not my problem if you don't like my
answer.
What is this with you, this is not a personal venetta?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 24 '07 #8
"Evertjan." "wrote":
>You asked what I would call it. It's not my problem if
you don't like my answer.

What is this with you, this is not a personal venetta?
It is not.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Dec 25 '07 #9

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

Similar topics

5
6489
by: Edward K. Ream | last post by:
Am I reading pep 277 correctly? On Windows NT/XP, should filenames always be converted to Unicode using the mbcs encoding? For example, myFile = unicode(__file__, "mbcs", "strict") This seems to work, and I'm wondering whether there are any other details to consider. My experiments with Idle for Python 2.2 indicate that os.path.join doesn't work as I expect when one of the args is a Unicode string. Everything
2
1681
by: Thomas Matthews | last post by:
Hi, I have a hierarchy of classes and would like to create an array of pointers to member functions that could also contain pointers to the parent member functions as well. What is the syntax for this? #include <string> using std::string;
4
6072
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3 script that grabs some web pages from the web, regex parse the data and stores it localy to xml file for further use.. at first i had no problem using python minidom and everything concerning
71
4364
by: ROSY | last post by:
1. How would you use the functions memcpy(), memset(), memmove()?
27
3389
by: Ben Jacobs-Swearingen | last post by:
Hello, I just started learning C a couple weeks ago from Kernighan and Ritchie (first edition -- I can't afford the newer second edition), and have really enjoyed it so far. But I am having trouble making the code at the end of Chapter 5 -- the sort function that uses function pointers -- to work on my machine (233 Mhz iMac, 160 MB RAM, OS 9.2 ; MPW environment). When I try to compile sort.c with the Symantec C compiler it gives me all...
72
4243
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and c?
2
2059
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking afterwards with ILDASM at what is visible in those assemblies from a managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method (defined on a 'Global Functions' class) in the generated assembly with an export name of the form
0
4949
by: Bruno Lavoie | last post by:
Hello, i'm etablishing a naming convention for a new project under postgresql. For tables, sequences, views, that's ok! I used good naming conventions for this in the past and i'll keep these rules for the new project. but, i plan to use a lot of triggers and functions in this project, but I'm confused! I know that triggers call already created functions. But for tracking i must be able to associate these 2 different object
28
2446
by: Martin Jørgensen | last post by:
Hi, I have a "funny" question, which I think is pretty "healthy" to examine... This program is being investigated: - - - - - - - #include <iostream> using namespace std; #define DAYS 7
9
4712
by: Let_Me_Be | last post by:
Hi all, I'm developing a small defensive programming toolkit for my own projects. So, here are my questions. 1) Is it possible to move from something like this: SAFECALL(foo();) to __safecall foo(); 2) I need to auto-add code to every method of particular class safeclass MyClass {
0
9699
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, 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...
0
9562
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,...
0
10304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
tracyyun
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...
0
9114
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, 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...
0
6838
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();...
0
5494
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...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2966
bsmnconsultancy
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...

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.