Google Groups Home
Help | Sign in
I7 Floating Point Maths
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Mike  
View profile
 More options Jul 19, 4:16 am
Newsgroups: rec.arts.int-fiction
From: Mike <mikec...@sky.com>
Date: Sat, 19 Jul 2008 01:16:03 -0700 (PDT)
Local: Sat, Jul 19 2008 4:16 am
Subject: I7 Floating Point Maths
A little while ago there were some threads on the lack of floating
point numbers in Inform 7.  It occured to me that it may be possible
to create a limited floating point number capability using the parts
of a number specification.  I have done some experimenting and come up
with a beta extension that allows limited use of floating point
numbers.

The extension needs some testing.  If you would like to use it, it is
available on the following link:

http://prolixic.inform7.googlepages.com/FloatingPointMaths.i7x

All comments and suggestions for improvements welcome.

Some words of warning:

I am a lawyer and priest by training, not a mathematician or computer
programmer so some of the functions may need refining.  Most of the
functions are calculated using brute force and ignorance.

Error checking routines have not yet been added so things like
division by 0, overflows, underflows and square roots of negative
numbers have not been trapped.

The extension requires the use of Glulx.

It is set up for four decimal places.  This can be changed but it
requires editing the extension.  Only numbers in the range
-214748.3648 to 214748.3647 are supported.

Documentation has to be added.

Mike


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dott.Piergiorgio  
View profile
 More options Jul 19, 6:40 am
Newsgroups: rec.arts.int-fiction
From: "dott.Piergiorgio" <dott.PiergiorgioNI...@KAIGUN.fastwebnet.it>
Date: Sat, 19 Jul 2008 12:40:22 +0200
Local: Sat, Jul 19 2008 6:40 am
Subject: Re: I7 Floating Point Maths
Mike ha scritto:

> I am a lawyer and priest by training,

O_o o_O O_O

what ?

Best regards from Italy,
Dott. Piergiorgio.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vaporware  
View profile
 More options Jul 19, 7:14 am
Newsgroups: rec.arts.int-fiction
From: vaporware <jmcg...@gmail.com>
Date: Sat, 19 Jul 2008 04:14:20 -0700 (PDT)
Local: Sat, Jul 19 2008 7:14 am
Subject: Re: I7 Floating Point Maths
On Jul 19, 1:16 am, Mike <mikec...@sky.com> wrote:

> A little while ago there were some threads on the lack of floating
> point numbers in Inform 7.  It occured to me that it may be possible
> to create a limited floating point number capability using the parts
> of a number specification.  I have done some experimenting and come up
> with a beta extension that allows limited use of floating point
> numbers.
[...]
> It is set up for four decimal places.  This can be changed but it
> requires editing the extension.  Only numbers in the range
> -214748.3648 to 214748.3647 are supported.

Technically, these are fixed point numbers, since they all have the
same number of decimal places.

Floating point combines a fixed point number with an exponent, so each
number can have a different number of decimal places. You could use
I7's units to make a floating point system too, as long as you don't
mind writing the numbers in scientific notation.

vw


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "I7 Fixed Point Maths Extension" by Mike
Mike  
View profile
 More options Jul 19, 12:49 pm
Newsgroups: rec.arts.int-fiction
From: Mike <mikec...@sky.com>
Date: Sat, 19 Jul 2008 09:49:59 -0700 (PDT)
Local: Sat, Jul 19 2008 12:49 pm
Subject: Re: I7 Fixed Point Maths Extension
On 19 Jul, 12:14, vaporware <jmcg...@gmail.com> wrote:

Fair comment!  Subject line changed accordingly.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Tarbert  
View profile
 More options Jul 19, 8:07 pm
Newsgroups: rec.arts.int-fiction
From: Mike Tarbert <miketarb...@embarqmail.com>
Date: Sat, 19 Jul 2008 20:07:59 -0400
Local: Sat, Jul 19 2008 8:07 pm
Subject: Re: I7 Fixed Point Maths Extension

Mike wrote:
> On 19 Jul, 12:14, vaporware <jmcg...@gmail.com> wrote:
>> On Jul 19, 1:16 am, Mike <mikec...@sky.com> wrote:
(snip)
>>> of a number specification.  I have done some experimenting and come up
>>> with a beta extension that allows limited use of floating point
>>> numbers.
>> Technically, these are fixed point numbers, since they all have the
>> same number of decimal places.

>> vw

> Fair comment!  Subject line changed accordingly.

This is pretty cool, Mike. I especially like your factorial function. I
know it's a standard definition, but I didn't know I7 funcs could do
that kind of self - referential recursion. Two quick things though,
you're missing a line in the tangent func:

To decide what fp_number is the tangent of (N - a fp_number):
        let temp1 be the sine of N;
        let temp2 be the cosine of N;
        let result be temp1 fp_divided by temp2;
        decide on result. [<-- missing line]

Also, I would recommend leaving out the paragraph break in your "To say
(N - a fp_number) as a number:" phrase. For the extension user, adding a
paragraph break is trivial, removing an existing one without rewriting
the phrase is impossible.

Skinny Mike


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike  
View profile
 More options Jul 20, 3:54 am
Newsgroups: rec.arts.int-fiction
From: Mike <mikec...@sky.com>
Date: Sun, 20 Jul 2008 00:54:36 -0700 (PDT)
Local: Sun, Jul 20 2008 3:54 am
Subject: Re: I7 Fixed Point Maths Extension
On 20 Jul, 01:07, Mike Tarbert <miketarb...@embarqmail.com> wrote:

Thanks for this Mike.  The changes have been made.  I will upload a
new version to the test site later today with some documentation and
additional functions added.

I take no credit for discovering that I7 can use recursive functions.
Emily posted on this subject many moons ago with an example using a
factorial function.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike  
View profile
 More options Jul 20, 12:28 pm
Newsgroups: rec.arts.int-fiction
From: Mike <mikec...@sky.com>
Date: Sun, 20 Jul 2008 09:28:45 -0700 (PDT)
Local: Sun, Jul 20 2008 12:28 pm
Subject: Re: I7 Fixed Point Maths Extension
On 20 Jul, 08:54, Mike <mikec...@sky.com> wrote:

Test version updated.  Now available on the following link (to reflect
the change of name):

http://prolixic.inform7.googlepages.com/FixedPointMaths.i7x

Mike


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ron Newcomb  
View profile
 More options Jul 20, 2:53 pm
Newsgroups: rec.arts.int-fiction
From: Ron Newcomb <psc...@yahoo.com>
Date: Sun, 20 Jul 2008 11:53:54 -0700 (PDT)
Local: Sun, Jul 20 2008 2:53 pm
Subject: Re: I7 Fixed Point Maths Extension
On Jul 20, 9:28 am, Mike <mikec...@sky.com> wrote:

> Test version updated.  Now available on the following link (to reflect
> the change of name):

> http://prolixic.inform7.googlepages.com/FixedPointMaths.i7x

> Mike

Hi Mike, I toyed around with the new version a tiny bit so far.

Is it really necessary to attached "fp_" onto everything?  It seems
very non-Inform.  For example, declare the unit as:

A real number is a kind of value.  -999999.9999 specifies a real
number with parts whole and fractional.

It reads better: "the fractional part of X".

Similarly for "fp_divided by" and the like.  I -think- you can get
away with just declaring it "divided by" and Inform will do the right
thing based on type (Unit vs. Number).  But if not, at least use
something like "exactly/precisely divided by" or some such.

I like "as an integer".  I use the same wording for typecasts. :)

"the reverse of X":  Shouldn't that be "to negate", or "the
negation"?

I think your "To decide which number is the greater part of (N - a
number):" function is just doing the same thing as the built-in "the
whole part of N"?   Similar for "lesser part of" and "fractional part
of N".   Although I understand defining synonyms for forgetful
authors, the fact that you use this function call (and associated
overhead) instead of the built-in method makes me wonder, especially
as it's a call to Divide.   Or have I misunderstood the purpose for
it?  I admit the necessity of the HalfDivisor business I'm not clear
on.

That's about all I had.  You put a lot of work into that, I can tell!

-R


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike  
View profile
 More options Jul 20, 3:23 pm
Newsgroups: rec.arts.int-fiction
From: Mike <mikec...@sky.com>
Date: Sun, 20 Jul 2008 12:23:44 -0700 (PDT)
Local: Sun, Jul 20 2008 3:23 pm
Subject: Re: I7 Fixed Point Maths Extension
On 20 Jul, 19:53, Ron Newcomb <psc...@yahoo.com> wrote:

I like that and will incorporate it into the released version.

> Similarly for "fp_divided by" and the like.  I -think- you can get
> away with just declaring it "divided by" and Inform will do the right
> thing based on type (Unit vs. Number).  But if not, at least use
> something like "exactly/precisely divided by" or some such.

I did try this with the original version but it sometimes threw up
errors where Inform 7 was expecting integers.  I think that this may
be because the extension allows you to include a real number and an
integer in a phrase such as "int fp_plus real" and this threw Inform 7
where I was using "int plus real".  Again this could be changed to
real plus, real minus, real times, real divided by.  Would this read
better?

> I like "as an integer".  I use the same wording for typecasts. :)

> "the reverse of X":  Shouldn't that be "to negate", or "the
> negation"?

I did think of something like this but it tends to give the impression
that the result is always a negative.  Would "X with its sign
reversed" be acceptable?

> I think your "To decide which number is the greater part of (N - a
> number):" function is just doing the same thing as the built-in "the
> whole part of N"?   Similar for "lesser part of" and "fractional part
> of N".   Although I understand defining synonyms for forgetful
> authors, the fact that you use this function call (and associated
> overhead) instead of the built-in method makes me wonder, especially
> as it's a call to Divide.   Or have I misunderstood the purpose for
> it?  I admit the necessity of the HalfDivisor business I'm not clear
> on.

The greater and lesser parts functions are internal housekeeping
ones.  For example, a real number is converted to an integer 1234.5678
becomes 12345678 before addition.  If the result is an integer
1234567890, the greater part of X returns 123456 and the lesser part
of X returns 7890.  These are used to build the answer as the real
number 123456.7890.

Half Divisor is used to determine, where appropriate whether the
fourth decimal place of a number needs to be rounded up.

> That's about all I had.  You put a lot of work into that, I can tell!

Thanks for your feedback.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ron Newcomb  
View profile
 More options Jul 20, 9:54 pm
Newsgroups: rec.arts.int-fiction
From: Ron Newcomb <psc...@yahoo.com>
Date: Sun, 20 Jul 2008 18:54:30 -0700 (PDT)
Local: Sun, Jul 20 2008 9:54 pm
Subject: Re: I7 Fixed Point Maths Extension
On Jul 20, 12:23 pm, Mike <mikec...@sky.com> wrote:

> where I was using "int plus real".  Again this could be changed to
> real plus, real minus, real times, real divided by.  Would this read
> better?

Well, if we've no choice, then it's better than underscores I guess.

OTOH, could you replace the built-in "plus" so that only a single To
phrase deals with all cases?

> > "the reverse of X":  Shouldn't that be "to negate", or "the
> I did think of something like this but it tends to give the impression
> that the result is always a negative.  Would "X with its sign
> reversed" be acceptable?

Er, I'll punt to the author by saying allow either:  the/a/an/--
reverse/negation of (N - a number)

> The greater and lesser parts functions are internal housekeeping
> ones.  For example, a real number is converted to an integer 1234.5678
> becomes 12345678 before addition.  If the result is an integer
> 1234567890, the greater part of X returns 123456 and the lesser part
> of X returns 7890.  These are used to build the answer as the real
> number 123456.7890.

Ah, that makes sense. Sorry to bring it up.

-R


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google