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

Prothon vs. Python integers

I think that in this case, Python is demonstrably better than Prothon.

C:\temp\prothon\Prothon>python
ActivePython 2.3.2 Build 232 (ActiveState Corp.) based on
Python 2.3.2 (#49, Nov 13 2003, 10:34:54) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
print 2**65 36893488147419103232
print 2**65 == (2**65 + 1) False
C:\temp\prothon\Prothon>prothon

Prothon 0.1 Interactive Console, Build 532, May 21 2004 (Ctrl-D to exit)
print 2** 65 3.68935e+19
print 2**65 == (2**65 + 1)

True

If Prothon is a language designed for the next ten years then it should
be tuned for correctness and ease of use, not for limitations of today's
hardware.

Paul Prescod

Jul 18 '05 #1
22 2187

"Paul Prescod" <pa**@prescod.net> wrote
I think that in this case, Python is demonstrably better than Prothon.

C:\temp\prothon\Prothon>python
ActivePython 2.3.2 Build 232 (ActiveState Corp.) based on
Python 2.3.2 (#49, Nov 13 2003, 10:34:54) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print 2**65 36893488147419103232
>>> print 2**65 == (2**65 + 1) False
C:\temp\prothon\Prothon>prothon

Prothon 0.1 Interactive Console, Build 532, May 21 2004 (Ctrl-D to exit)
>>> print 2** 65 3.68935e+19
>>> print 2**65 == (2**65 + 1)

True

If Prothon is a language designed for the next ten years then it should
be tuned for correctness and ease of use, not for limitations of today's
hardware.


I'm sure this isn't the only place Python is better.

Prothon has the long integer support in the parser if anyone wants to take
the trouble to put the long object code in. I did nothing to preclude it. I
just didn't see any need for it myself and didn't take the trouble to put it
in.

Longs seemed like a needless exotic kludge to me in the 64-bit world. Surely
once you get to 3.7e19 you are in floating point territory. I can't imagine
counting anything up to 10**19.
Jul 18 '05 #2
On Mon, 24 May 2004 11:31:08 -0700,
"Mark Hahn" <ma**@prothon.org> wrote:
"Paul Prescod" <pa**@prescod.net> wrote
[ snip ]
Prothon 0.1 Interactive Console, Build 532, May 21 2004 (Ctrl-D to exit)
>>> print 2** 65

3.68935e+19
>>> print 2**65 == (2**65 + 1)

True If Prothon is a language designed for the next ten years then
it should be tuned for correctness and ease of use, not for
limitations of today's hardware.

I'm sure this isn't the only place Python is better. Prothon has the long integer support in the parser if anyone
wants to take the trouble to put the long object code in. I did
nothing to preclude it. I just didn't see any need for it myself
and didn't take the trouble to put it in. Longs seemed like a needless exotic kludge to me in the 64-bit
world. Surely once you get to 3.7e19 you are in floating point
territory. I can't imagine counting anything up to 10**19.


Beans? ;-)

Accountants ("bean counters," in the derogatory vernacular) will
be displeased if Prothon silently loses pennies (or other small-
valued currencies) after a certain amount (lira and drachma spring
to mind, too).

Also, modern day cryptography applications can demand integer/
logical operations on 256-, 512-, or more- bit (upwards of 1e150)
integers.

Regards,
Heather

--
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli
Jul 18 '05 #3

"Heather Coppersmith" <me@privacy.net> wrote in message
news:m2************@unique.phony.fqdn...
Longs seemed like a needless exotic kludge to me in the 64-bit
world. Surely once you get to 3.7e19 you are in floating point
territory. I can't imagine counting anything up to 10**19.
Beans? ;-)

Accountants ("bean counters," in the derogatory vernacular) will
be displeased if Prothon silently loses pennies (or other small-
valued currencies) after a certain amount (lira and drachma spring
to mind, too).


No economy is ever going to to have a gdp of 10**19 pennies.
Also, modern day cryptography applications can demand integer/
logical operations on 256-, 512-, or more- bit (upwards of 1e150)
integers.


Are Python longs being used for those? I guess even if they aren't someone
might want to evaluate algorithms using longs.

Ok, I'm wrong once again. I'll put implementing longs on the to-do list.
Jul 18 '05 #4
Heather Coppersmith wrote:
Also, modern day cryptography applications can demand integer/
logical operations on 256-, 512-, or more- bit (upwards of 1e150)
integers.


Also, number theorists certainly would care.

--
__ Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ A war at sea. A war with no battles, no monuments ... only
casualties. -- Capt. Marko Ramius
Jul 18 '05 #5
On 24 May 2004 15:05:55 -0400, rumours say that Heather Coppersmith
<me@privacy.net> might have written:
(lira and drachma spring
to mind, too)


Lira? Drachma? Too late for that... There are lots of children in
both countries that had their lunch money always in euros.

PS A funny incident from the transition period to the euro: in a small
shop, an elderly lady is before me in front of the counter.

Lady: "How much is it?"
Clerk: "4.2 euros"
Lady: "No, I mean in *money*, how much is it?"

The translation might not be as strong as the original, but I loved it
so much, that since then, whenever I did conversions out loud, it was
"euros" to "money", never "drachmae" :)
--
TZOTZIOY, I speak England very best,
"I have a cunning plan, m'lord" --Sean Bean as Odysseus/Ulysses
Jul 18 '05 #6
"Mark Hahn" <ma**@prothon.org> wrote in message news:<Mbrsc.15253$bF3.12865@fed1read01>...
"Paul Prescod" <pa**@prescod.net> wrote
I think that in this case, Python is demonstrably better than Prothon.

C:\temp\prothon\Prothon>python
ActivePython 2.3.2 Build 232 (ActiveState Corp.) based on
Python 2.3.2 (#49, Nov 13 2003, 10:34:54) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print 2**65 36893488147419103232
>>> print 2**65 == (2**65 + 1)

False
C:\temp\prothon\Prothon>prothon

Prothon 0.1 Interactive Console, Build 532, May 21 2004 (Ctrl-D to exit)
>>> print 2** 65

3.68935e+19
>>> print 2**65 == (2**65 + 1)

True

If Prothon is a language designed for the next ten years then it should
be tuned for correctness and ease of use, not for limitations of today's
hardware.


I'm sure this isn't the only place Python is better.

Prothon has the long integer support in the parser if anyone wants to take
the trouble to put the long object code in. I did nothing to preclude it. I
just didn't see any need for it myself and didn't take the trouble to put it
in.

Longs seemed like a needless exotic kludge to me in the 64-bit world. Surely
once you get to 3.7e19 you are in floating point territory.


Unless you're working on problems in Number Theory, in which every single
decimal digit of 2**177525 - 1 is significant.
I can't imagine counting anything up to 10**19.


Not every sequence increments by 1. Putting 2**177525 - 1 into the Collatz
Conjecture results in a mere 2.5 million iterations, not 10**53000.
Limiting the loop counts to <10**19 doesn't mean you have to limit
the values.
Jul 18 '05 #7
Heather Coppersmith <me@privacy.net> wrote in message news:<m2************@unique.phony.fqdn>...
....
Longs seemed like a needless exotic kludge to me in the 64-bit
world. Surely once you get to 3.7e19 you are in floating point
territory. I can't imagine counting anything up to 10**19.
Beans? ;-)

Accountants ("bean counters," in the derogatory vernacular) will
be displeased if Prothon silently loses pennies (or other small-
valued currencies) after a certain amount


Or credit card numbers. They're 16 digits long, and Microsoft Excel
has this inconvenient feature of displaying them with 15 significant
digits.
(lira and drachma spring to mind, too).


The Italian Lira and Greek Drachma have been replaced by the Euro.

However, the *Turkish* lira hasn't, and I think it takes 500 000 of
those just to buy a candy bar.
Jul 18 '05 #8
"Mark Hahn" <ma**@prothon.org> writes:
Longs seemed like a needless exotic kludge to me in the 64-bit world. Surely
once you get to 3.7e19 you are in floating point territory. I can't imagine
counting anything up to 10**19.


Aaaargh !

Please don't do this. Please don't make language design decisions on
the basis of your lack of imagination. It's a very good way of
designing a crap language.
Jul 18 '05 #9
Mark Hahn wrote:
Longs seemed like a needless exotic kludge to me in the 64-bit world. Surely
once you get to 3.7e19 you are in floating point territory. I can't imagine
counting anything up to 10**19.


Except all those sad people doing that thing called 'maths'.

Sorry but one of my requirements for a language is that is can handle integers of any size quickly and easily (and a good integer square root would be nice). However I always seem to
end up coding with C and GMP.
Jul 18 '05 #10
On 24 May 2004 23:49:42 -0700,
da*****@yahoo.com (Dan Bishop) wrote:
Heather Coppersmith <me@privacy.net> wrote in message news:<m2************@unique.phony.fqdn>...
Accountants ("bean counters," in the derogatory vernacular)
will be displeased if Prothon silently loses pennies (or other
small- valued currencies) after a certain amount

Or credit card numbers. They're 16 digits long, and Microsoft
Excel has this inconvenient feature of displaying them with 15
significant digits.


Credit card numbers aren't integers, though; they just look like
integers (modulo the internal spaces) when you print them out (not
unlike U.S. postal codes, which consist of five or nine digits).
Excel overzealously converts all such entries to mathematical
objects. What does it mean, for example, to multiply your credit
card number by three?

Regards,
Heather

--
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli
Jul 18 '05 #11
Mark Hahn <ma**@prothon.org> wrote:
No economy is ever going to to have a gdp of 10**19 pennies.


Turkey's is around 10**18 lira (obtained from 2002 GDP in $ and
current exchange rate). You could argue that by the time they
hit 10**19 they'll have got EU membership and gone over to the
Euro....

(Japan's GDP appears to be around 10**16Y, BTW.)

Given the number of times we see newbies confused by Python's
handling of floating points, it strikes me that silent conversion
of overflowing ints to doubles is asking for trouble somewhere
down the line, and should be avoided if possible.

--
\S -- si***@chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomež se bera eadward ofdun hlęddre heafdes bęce bump bump bump
Jul 18 '05 #12
Heather Coppersmith wrote:
objects. What does it mean, for example, to multiply your credit
card number by three?


I get three credit cards and go on a shopping spree?
Jul 18 '05 #13

"Jacek Generowicz" <ja**************@cern.ch> wrote in message
news:ty*************@pcepsft001.cern.ch...
"Mark Hahn" <ma**@prothon.org> writes:
Longs seemed like a needless exotic kludge to me in the 64-bit world. Surely once you get to 3.7e19 you are in floating point territory. I can't imagine counting anything up to 10**19.


Aaaargh !

Please don't do this. Please don't make language design decisions on
the basis of your lack of imagination. It's a very good way of
designing a crap language.


I said yesterday noon in this same thread I was wrong and was implementing
longs. Please give me a break.
Jul 18 '05 #14

"Peter Hickman" <pe***@semantico.com> wrote
Longs seemed like a needless exotic kludge to me in the 64-bit world. Surely once you get to 3.7e19 you are in floating point territory. I can't imagine counting anything up to 10**19.
Except all those sad people doing that thing called 'maths'.

Sorry but one of my requirements for a language is that is can handle

integers of any size quickly and easily (and a good integer square root
would be nice). However I always seem to end up coding with C and GMP.


I said in this thread at noon yesterday that I was wrong and that I will
implement longs.
Jul 18 '05 #15
On 25 May 2004 07:02:09 -0400, rumours say that Heather Coppersmith
<me@privacy.net> might have written:
What does it mean, for example, to multiply your credit
card number by three?


I instantly become more attractive?-)
--
TZOTZIOY, I speak England very best,
"I have a cunning plan, m'lord" --Sean Bean as Odysseus/Ulysses
Jul 18 '05 #16
da*****@yahoo.com (Dan Bishop) wrote:
Or credit card numbers. They're 16 digits long, and Microsoft Excel
has this inconvenient feature of displaying them with 15 significant
digits.


I'm not sure credit card numbers are really numbers. I think of them
more as strings. The fact that they're made up only of digits is almost
meaningless, since you don't generally do any arithmetic operations on
them. You record them someplace and spit them back when needed. Even
as database keys, you're more likely to hash them than to use their
arithmetic value directly.

One common operation is to figure out which vendor owns a certain
number, and you do that by looking at the first four digits. Thinking
of it as a string, you would do "substring (digitString, 0, 4)".
Thinking of it as an integer, you would do "int (value / 1000000000)".
Which would you do?

Another common example of digit strings which aren't really numeric
values is a telephone number. If I've counted properly, to call a
number in London, England using my calling card, I need to dial 31
digits (access number + 01 + country code + local number + auth code +
PIN). Sure, they're all digits, but I think any sane system would store
that as a string, especially given that the only operation I ever want
to do with the sub-parts is concatenate them in various ways.
Jul 18 '05 #17
Sion Arrowsmith wrote:
Mark Hahn <ma**@prothon.org> wrote:
No economy is ever going to to have a gdp of 10**19 pennies.


Turkey's is around 10**18 lira (obtained from 2002 GDP in $ and
current exchange rate). You could argue that by the time they
hit 10**19 they'll have got EU membership and gone over to the
Euro....

(Japan's GDP appears to be around 10**16Y, BTW.)

Given the number of times we see newbies confused by Python's
handling of floating points, it strikes me that silent conversion
of overflowing ints to doubles is asking for trouble somewhere
down the line, and should be avoided if possible.


I've agreed to adding longs. I'm thinking of only having longs.
Jul 18 '05 #18
Mark Hahn wrote:

Surely
once you get to 3.7e19 you are in floating point territory.


Incorrect. You're only ever in floating point territory
if you can tolerate inexact results. Some applications
can't.

Even if you don't support arbitrary-size integers, you
should *not* automatically overflow from ints to floats.
You should raise an exception instead. That way, people
won't be bitten by unexpected loss of precision.

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg

Jul 18 '05 #19
Greg Ewing wrote:
Surely
once you get to 3.7e19 you are in floating point territory.


Incorrect. You're only ever in floating point territory
if you can tolerate inexact results. Some applications
can't.

Even if you don't support arbitrary-size integers, you
should *not* automatically overflow from ints to floats.
You should raise an exception instead. That way, people
won't be bitten by unexpected loss of precision.


I've agreed to support longs and I'm thinking of only having longs.
Jul 18 '05 #20
On Tue, 25 May 2004 17:59:20 -0700, Mark Hahn wrote:
I've agreed to adding longs. I'm thinking of only having longs.


It's more efficient if ints which fit in a machine word (or a machine word
minus one or two bits used for tagging them as ints) are represented as
such, rather than using a generic big int representation.

It doesn't mean they should be treated differently in the language.
It can be a hidden implementation detail, visible only for those who write
extensions in C.

--
__("< Marcin Kowalczyk
\__/ qr****@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/

Jul 18 '05 #21
Marcin 'Qrczak' Kowalczyk wrote:
It's more efficient if ints which fit in a machine word (or a machine word
minus one or two bits used for tagging them as ints) are represented as
such, rather than using a generic big int representation.


Seems like it should be possible to implement big numbers in a way that
small numbers are nearly as, as, or more efficient than machine integers,
when you take into account the overflow checking needed for regular
integers in a language like python.

Jul 18 '05 #22
Marcin 'Qrczak' Kowalczyk wrote:
On Tue, 25 May 2004 17:59:20 -0700, Mark Hahn wrote:
I've agreed to adding longs. I'm thinking of only having longs.


It's more efficient if ints which fit in a machine word (or a machine
word minus one or two bits used for tagging them as ints) are
represented as such, rather than using a generic big int
representation.

It doesn't mean they should be treated differently in the language.
It can be a hidden implementation detail, visible only for those who
write extensions in C.


I've already implemented the new ints in Prothon. They behave as normal
ints until an overflow occurs and then they are treated as a bigint. There
is no performance penalty at all because I have to check for overflow
anyway.

C extension coders see no difference unless they want to deal with bigints.
Macros provide access to the ints and if they ask for a normal size int that
is actually a bigint it just throws an excepton.


Jul 18 '05 #23

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

Similar topics

0
by: Mark Hahn | last post by:
I would like to announce a new interpreted object-oriented language very closely based on Python, that is Prototype-based, like Self (http://research.sun.com/research/self/language.html) instead of...
0
by: Mark Hahn | last post by:
Ben Collins and I have developed a new interpreted object-oriented language very closely based on Python, that is Prototype-based, like Self (http://research.sun.com/research/self/language.html)...
145
by: David MacQuigg | last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating classes in Python. I'm trying to figure out what fundamental benefit there is to having classes. Is all this complexity...
27
by: Michele Simionato | last post by:
> Hello, my name is Skip and I am metaclass-unaware. I've been programming in > Python for about ten years and I have yet to write a metaclass. At first I > thought it was just that metaclasses...
29
by: Mark Hahn | last post by:
We are considering switching to the dollar sign ($) for self, instead of the period ( . ) we are using now in Prothon. Ruby uses the at-sign (@) for self, but our new usage of self also includes...
28
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are...
25
by: Mark Hahn | last post by:
There is a new release of Prothon that I think is worth mentioning here. Prothon version 0.1.0 has changed almost beyond recognition compared to what was discussed here before. For example: the...
49
by: Mark Hahn | last post by:
As we are addressing the "warts" in Python to be fixed in Prothon, we have come upon the mutable default parameter problem. For those unfamiliar with the problem, it can be seen in this Prothon...
20
by: Mark Hahn | last post by:
Prothon is pleased to announce another major release of the language, version 0.1.2, build 710 at http://prothon.org. This release adds many new features and demonstrates the level of maturity...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
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...
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.