Click Here
home features news forums classifieds faqs links search
6071 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
12 crawler(s) on-line.
 120 guest(s) on-line.
 1 member(s) on-line.


 agami

You are an anonymous user.
Register Now!
 agami:  37 secs ago
 Seiya:  1 hr 42 mins ago
 matthey:  2 hrs 4 mins ago
 Rob:  3 hrs 14 mins ago
 vox:  3 hrs 18 mins ago
 kolla:  4 hrs 12 mins ago
 mbrantley:  4 hrs 14 mins ago
 pixie:  4 hrs 37 mins ago
 FerruleMedia:  4 hrs 45 mins ago
 amigakit:  4 hrs 58 mins ago

/  Forum Index
   /  Amiga Development
      /  [E] Power operator
Register To Post

PosterThread
r-tea 
[E] Power operator
Posted on 5-May-2018 19:50:38
#1 ]
Regular Member
Joined: 21-Nov-2004
Posts: 315
From: Zdzieszowice, Poland

Is there a power operator or function in AmigaE standard package? I have looked through all the Beginner's Guide and haven't found one.

_________________
I miss draggable screens in MorphOS... and do you? I know I'm in a minority unfortunately.

 Status: Offline
Profile     Report this post  
bison 
Re: [E] Power operator
Posted on 5-May-2018 20:01:21
#2 ]
Elite Member
Joined: 18-Dec-2007
Posts: 2112
From: N-Space

@r-tea

Did you look for a function named pow or Pow?

Update: bad news.

Quote:
Pow() returns a raised to the power b. This procedure was not present in AmigaE.

http://cshandley.co.uk/portable/StandardFunctionality.html

Last edited by bison on 05-May-2018 at 08:04 PM.

_________________
"Unix is supposed to fix that." -- Jay Miner

 Status: Offline
Profile     Report this post  
r-tea 
Re: [E] Power operator
Posted on 5-May-2018 20:16:30
#3 ]
Regular Member
Joined: 21-Nov-2004
Posts: 315
From: Zdzieszowice, Poland

@bison

Of course. I have looked for Exp(onent) as well as for "^" operator but there's none of them.

Maybe anyone knows an external AmigaE (not PortablE or CreativE) math mudule containing some extra functions?

_________________
I miss draggable screens in MorphOS... and do you? I know I'm in a minority unfortunately.

 Status: Offline
Profile     Report this post  
bison 
Re: [E] Power operator
Posted on 5-May-2018 20:48:01
#4 ]
Elite Member
Joined: 18-Dec-2007
Posts: 2112
From: N-Space

@r-tea

I worked in tech support for three years, so I never assume anything.

If it's just for integers, you could write your own function. I'm not familiar with AmigaE syntax, but this works in python:

def mypow(x, y):
result = 1
while y > 0:
result *= x
y -= 1
return result

Correction: this would work if our idiot message-board software didn't strip leading white space.

Update: fixed formatting.

Last edited by bison on 06-May-2018 at 04:14 AM.

_________________
"Unix is supposed to fix that." -- Jay Miner

 Status: Offline
Profile     Report this post  
broadblues 
Re: [E] Power operator
Posted on 6-May-2018 1:00:22
#5 ]
Amiga Developer Team
Joined: 20-Jul-2004
Posts: 4446
From: Portsmouth England

@bison

Hmmm?


def mypow(x, y):
result = 1
while y > 0:
result *= x
y -= 1
return result


If the "idiot message board" user remebered about the <pre> ... <//pre> html tags there would be no problem

_________________
BroadBlues On Blues BroadBlues On Amiga Walker Broad

 Status: Offline
Profile     Report this post  
bison 
Re: [E] Power operator
Posted on 6-May-2018 3:33:47
#6 ]
Elite Member
Joined: 18-Dec-2007
Posts: 2112
From: N-Space

@broadblues

It's not a matter of remembering -- I never knew that in the first place! For some reason I didn't think I could use HTML in posts, just the square bracket tags. Thanks for the tip. I will try to do better.

But... I won't stop calling it the Idiot Message Board Software until it stops doing that blank post thing that happens every now and again.

Last edited by bison on 06-May-2018 at 03:35 AM.

_________________
"Unix is supposed to fix that." -- Jay Miner

 Status: Offline
Profile     Report this post  
simplex 
Re: [E] Power operator
Posted on 6-May-2018 6:58:38
#7 ]
Cult Member
Joined: 5-Oct-2003
Posts: 896
From: Hattiesburg, MS

@bison

This will be slow. You guys might want to look up fast exponentiation. That said, none of these methods work if he needs a non-integral power.

_________________
I've decided to follow an awful lot of people I respect and leave AmigaWorld. If for some reason you want to talk to me, it shouldn't take much effort to find me.

 Status: Offline
Profile     Report this post  
r-tea 
Re: [E] Power operator
Posted on 6-May-2018 18:43:53
#8 ]
Regular Member
Joined: 21-Nov-2004
Posts: 315
From: Zdzieszowice, Poland

Thank you guys.
Actually I need powering only for few values of a single byte [128, 64, 32,16, 8, 4, 2, 1]. Then I realised that I can easily workarond that problem by simply providing that values in an array or list (it's AmigaE). Finally I managed it w/o powering.

BTW, its for some enhancements in new, upcoming Hexaco toy/tool located on Aminet

Last edited by r-tea on 06-May-2018 at 06:49 PM.

_________________
I miss draggable screens in MorphOS... and do you? I know I'm in a minority unfortunately.

 Status: Offline
Profile     Report this post  
Fl@sh 
Re: [E] Power operator
Posted on 6-May-2018 18:59:05
#9 ]
Regular Member
Joined: 6-Oct-2004
Posts: 253
From: Napoli - Italy

@r-tea

Faster and smarter

_________________
Pegasos II G4@1GHz 2GB Radeon 9250 256MB
AmigaOS4.1 fe - MorphOS - Debian 9 Jessie

 Status: Offline
Profile     Report this post  
Deniil715 
Re: [E] Power operator
Posted on 6-May-2018 19:31:47
#10 ]
Elite Member
Joined: 14-May-2003
Posts: 4236
From: Sweden

@r-tea

You can use the mathieeesingbas.library. There is Fpow() I think. I have used it a few times. Of course, these are all float functions. Don't think you even need to open the library to use the functions since you will anyway need an '!' somewhere in the code, which will make AmigaE to open it for you.

_________________
- Don't get fooled by my avatar, I'm not like that (anymore, mostly... maybe only sometimes)
> Amiga Classic and OS4 developer for OnyxSoft.

 Status: Offline
Profile     Report this post  
bison 
Re: [E] Power operator
Posted on 6-May-2018 21:16:05
#11 ]
Elite Member
Joined: 18-Dec-2007
Posts: 2112
From: N-Space

@simplex

Quote:
This will be slow.

Yes, you are right.

My strategy is to start simple and only optimize what proves to be unacceptably slow. This practice comes from having to maintain my own code.

@r-tea

I like your solution. It's simple and fast.

_________________
"Unix is supposed to fix that." -- Jay Miner

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: [E] Power operator
Posted on 6-May-2018 21:59:26
#12 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12817
From: Norway

@r-tea

Don't you have shift rotate on AmigaE?

That number sequence is power of 2.

you do this in C.



1<<0 = 1
1<<1 = 2
1<<2 = 4
1<<4 = 8
1<<5 = 16

Last edited by NutsAboutAmiga on 06-May-2018 at 10:00 PM.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
tonyw 
Re: [E] Power operator
Posted on 6-May-2018 23:53:37
#13 ]
Elite Member
Joined: 8-Mar-2003
Posts: 3240
From: Sydney (of course)

@NutsAboutAmiga

I think you mean:

1<<0 = 1
1<<1 = 2
1<<2 = 4
1<<4 = 16 *
1<<5 = 32 *

Last edited by tonyw on 06-May-2018 at 11:57 PM.
Last edited by tonyw on 06-May-2018 at 11:54 PM.

_________________
cheers
tony

Hyperion Support Forum: http://forum.hyperion-entertainment.biz/index.php

 Status: Offline
Profile     Report this post  
bison 
Re: [E] Power operator
Posted on 7-May-2018 1:16:41
#14 ]
Elite Member
Joined: 18-Dec-2007
Posts: 2112
From: N-Space

@NutsAboutAmiga

That works if the left operand is 1, but if its something else, say 2, then you have to handle that as a special case, since 2^0 is 1, not 2.

And of course, in all these methods we're talking about, you have add code to check for integer overflow or shifting the sign bit in twos-complement representation.

I think @r-tea's solution of pre-computing the results is the best solution to the problem is trying to solve.

Update: corrected spelling/grammar errors. If I see any more, I will ignore them and hope it still make sense.

Last edited by bison on 07-May-2018 at 01:26 AM.
Last edited by bison on 07-May-2018 at 01:23 AM.
Last edited by bison on 07-May-2018 at 01:23 AM.

_________________
"Unix is supposed to fix that." -- Jay Miner

 Status: Offline
Profile     Report this post  
simplex 
Re: [E] Power operator
Posted on 7-May-2018 2:09:31
#15 ]
Cult Member
Joined: 5-Oct-2003
Posts: 896
From: Hattiesburg, MS

@bison

Quote:
My strategy is to start simple and only optimize what proves to be unacceptably slow.

Wise. "Premature optimization is the root of all evil." -- Donald Knuth

That said, the algorithm I linked to is wonderful.

_________________
I've decided to follow an awful lot of people I respect and leave AmigaWorld. If for some reason you want to talk to me, it shouldn't take much effort to find me.

 Status: Offline
Profile     Report this post  

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle