Subject: MAX Digest - 5 Aug 1998 to 6 Aug 1998
Date: Fri, 7 Aug 1998 00:00:00 -0400
From: Automatic digest processor 
Reply-To: MAX - Interactive Music/Multimedia Standard Environments
     
To: Recipients of MAX digests 

There are 13 messages totalling 478 lines in this issue.

Topics of the day:

  1. floats' displayed precision? (4)
  2. floats
  3. floats (not again!)
  4. mtr (2)
  5. umenu wierdness
  6. floats and 18.8
  7. MAX Digest - 4 Aug 1998 to 5 Aug 1998
  8. umenu
  9. menubar and standalone applications.

Email to MAX should now be sent to MAX@lists.mcgill.ca
LISTSERV commands should be sent to listserv@lists.mcgill.ca
Information is available on the WEB at http://www.mcgill.ca/cc/listserv

----------------------------------------------------------------------

Date:    Thu, 6 Aug 1998 00:54:10 -0400
From:    Burton Alexandre 
Subject: Re: floats' displayed precision?

> Here's the dope. Listen carefully, I'm only going to say this once:

 snip:[discussion on how floats are stored in binary form]

> The above is slightly simplified, but anyone who cares about the details
> probably knows them already.

 You're obviously confusing representation and storage. IEEE854 allows the
base of the floats to be ten, even if it's represented in binary format.
How come? I think there's an old document called "What Every Computer
Scientist Should Know About Floating Point Arithmetic" lying around; i
don't pretend being a computer scientist, but i recall having some insight
reading it.

 But that's way too low-level for our discussion. We're (probably) stuck
with base-2 floating point format (one of the many methods to store real
numbers in binary; we unfortunately tend to equate "floating point" to
"real" because it's so common).

> I dunno, binary computers have been with us for over half a century, I
> had binary arithmetic in grade school (which is getting closer to a half
> century ago then I care to think about), and people still get surprised
> about artifacts of binary arithmetic. Oh, well.-\

 People get surprised that a representation object (the number box) does
not deal with representation. Oh, well.-\

 Folks get surprised that a data object (the coll) does not deal with
data integrity. Oh, well.-\

 "Artifacts of binary arithmetic", as you have it, falls into a set of
problems to which solutions have been found. None are perfect, you have a
limited amount of bits available; there's always a rounding error. The
decision is up to the implementor.  But here we're talking of
representation.

  No need for an "accuracy" message (probably feeding a C format?
brrr...). Steele and White proposed a while ago: "When converting a value
to a string, convert to the smallest number of digits such that converting
back yields the original value again."  (Like, if 11.8 converts to the
same as 11.799998, use 11.8 when converting 11.799998 to a string. They're
both the same to the machine.).

 Max is a (very) high-level programming language and from my point of
view, at that level, showing something like 11.799998 is wrong.

> Peter -- muttering something to himself about "what do they teach kids at
> school nowadays?"

 ?

 You know, we're not 50 years ago anymore.

 So my question, more direct (i admit my original post was a little on
the vague side): how does one cope with the fact Max does not deal
elegantly with (decimal) string representation *and* does not provide a
formatting function? I'd really like to see 18.8.

                                                Alex Burton.

 p.s. i apologize to the list for the tone of this reply, but i tend to
tune to what's sent to me.

------------------------------

Date:    Thu, 6 Aug 1998 00:58:55 -0400
From:    Burton Alexandre 
Subject: Re: floats

Peter Elsea:

> The way to keep your numbers
> looking pretty is to round them and (Here comes the plug) there's an
> Lobject that does that. Lround implements the "round to nearest or even"
> algorithm and lets you specify the precision. To display 11.8 send the
> 11.799998 through Lround 1.

 Thanks for the tip!

                                                        Alex.

------------------------------

Date:    Thu, 6 Aug 1998 01:11:57 -0400
From:    Burton Alexandre 
Subject: Re: floats (not again!)

 Peter, i tried your Lround but it does not solve the problem at hand
(decimal representation of binary-stored floats). For some fun, connect a
float box to Lround 1 to a float box and drag the top one. Some numbers
do get rounded in a way that they fall on a correct binary patterns, but
18.8 is not one of them.  :(

 (I may seem to have a weird emotional relationship with the number 18.8,
but it happens to be used by a piece of hardware i'm trying to tame...)

                                                Alex.

------------------------------

Date:    Thu, 6 Aug 1998 02:16:44 EDT
From:    "Britt H. Myers" 
Subject: mtr

Has anyone had experience dealing with the "mtr" object to create a
multitrack
sequencer?

Even with the tutorial patch, the playback has a flangy effect, like the
midi
data is being doubled.  Local control is off, but it shouldn't matter anyway
because mtr is just playing back what I put into it already.  This effect
happens in the patches I've made with mtr too.

Any suggestions?  Does mtr typically have this problem?

Thanks

Britt

------------------------------

Date:    Thu, 6 Aug 1998 02:42:11 -0500
From:    Hosken 
Subject: Re: floats' displayed precision?

>From:    Peter Castine 
>
>Think BINARY!
>Think BINARY!!
>Think BINARY!!!!

I don't want to! I don't want to!! I don't want to!!!!

I appreciate Peter's careful explanation (this wasn't my issue--I'm just
getting in on the action), but I beg to differ a bit philosophically with
his commentary. When human reasoning (and decimal arithmetic) come into
conflict with binary computation, why is the human at fault for not
conforming his/her thinking to match the computer's arithmetic? Another
way to say this is that binary computers have been with us for over half
a century and have yet to come up to our standards. I mean no disrespect
to David Z. and the other wonderful people that make computer tools
available for creative use, but it seems odd to blame a person for
failing to comprehend why 11.8 is not just good ole 11.8. Particularly
when kind-hearted computer programmers have gone to such pains to hide
the distinctions between our mode of thinking and the underlying
computations.

It's reasonable to expect a person to change their thinking when
interfacing with something new (a new person, a new car, a new program,
etc.), but I don't think that we should deem every required change in
thinking to be a positive thing.

Before the thought enters someone's mind (or someone's flame), my
education has left me capable of reasoning through the issue of floating
point binary representation. But day to day, even with most of it spent
in front of a computer, it's just not part of my life.

>I dunno, binary computers have been with us for over half a century, I
>had binary arithmetic in grade school (which is getting closer to a half
>century ago then I care to think about), and people still get surprised
>about artifacts of binary arithmetic. Oh, well.-\

Again restated: ...and people still have to deal with artifacts of binary
arithmetic?

Dan Hosken
dwhosken@alum.mit.edu

------------------------------

Date:    Thu, 6 Aug 1998 08:35:38 -0500
From:    evening 
Subject: Re: umenu wierdness

Thanks for all of your help with this - I guess I'll be using a text
editor.

jmw

------------------------------

Date:    Thu, 6 Aug 1998 08:56:36 -0400
From:    Chris Murtagh Hrdc-drhc 
Subject: Re: floats' displayed precision?

From: "Burton Alexandre" , on 8/6/98 12:54 AM:
>  No need for an "accuracy" message (probably feeding a C format?
>brrr...). Steele and White proposed a while ago: "When converting a value
>to a string, convert to the smallest number of digits such that converting
>back yields the original value again."  (Like, if 11.8 converts to the
>same as 11.799998, use 11.8 when converting 11.799998 to a string. They're
>both the same to the machine.).

 There is a slight problem with the logic here. How is your algorithm
supposed to know what the 'True' number you wanted? Since it has no way to
encode the number 11.8, it can't tell if that was the number you really
wanted and not 11.7999989989 (these are very different numbers). The only
'real' solution is BCD, but that involves way too much overhead for
something that people should just learn to deal with. Another 'fudged'
solution is to have a special hacked 'fixed precision' type of number box
so that it will round up things for people who can't deal with IEEE and
binary representation. -> printf("Fudged = %.3f",Float);

> Max is a (very) high-level programming language and from my point of
>view, at that level, showing something like 11.799998 is wrong.

Then code the variable fixed-precision(oxymoron?) number box. It seems to
be the simplest solution, but remember, it isn't giving you any more
accuracy, only visually fooling you into thinking it is more accurate. I
don't see the point of it however, as I would much rather be able to see
potential errors/inaccuracies especially when debugging something that is
relying on a certain degree of precision.

Anyway, just my $0.02. <-- accurately represented in IEEE.

Chris

"Never ask a man what sort of computer he drives. If it's a Mac, he'll tell
you. If not, why embarrass him?" -- Tom Clancy

------------------------------

Date:    Thu, 6 Aug 1998 11:34:47 -0400
From:    Stephen Kay 
Subject: Re: floats and 18.8

>Peter, i tried your Lround but it does not solve the problem at hand
>(decimal representation of binary-stored floats).

Actually, this appears to be a bug.  Lround 1 does *not* round certain
floats, including 18.8.  Very bizarre.  Or maybe it *is* actually
performing the rounding correctly; but once again when it sends out
18.8, there is no object in Max capable of displaying that particular
number, (including print) since they all apparently use the same =

method to convert a float to a string, so once again it becomes =

18.7999999.

So, I started fooling around a bit.  It turns out that the MegaMAX
objects which can display floats *will* display 18.8.  For example,
if you attach a float numbox to a prepend text to a <3D_Label>,
typing in 18.8 in the numbox displays '18.799999' in the numbox, but
'18.8' in the <3D_Label>.

So, if it's of any interest to anyone, here's what I use to convert
a float to text.  This function is used by all MegaMAX Objects which
can be passed an unknown item to display - for those who are not C
programmers, an unknown item in Max is an "Atom", which has a "type
field" specifying whether the data is a long, a float, a symbol, etc.

The "char *sub" is a pointer to a default C-string to use in case
the user sent in an empty symbol, or a blank symbol.

I don't know why this displays 18.8 correctly; maybe someone else
can figure it out.  Perhaps it has something to do with the "%g"
format specifier to sprintf - this was done a really long time
ago and I don't remember how I arrived at this, but I do remember
it took awhile.  However, using %g in the Max sprintf object
doesn't produce 18.8 :-(

Symbol *MakeSymbol(Atom av, char *sub)
{
  Symbol *temp_sym;
  Str255 temp_string;
  char buffer[30];

        if (av.a_type =3D=3D A_LONG){
                NumToString(av.a_w.w_long, temp_string);

        }else if (av.a_type =3D=3D A_FLOAT){
                sprintf(buffer + 1, "%g", (double)av.a_w.w_float);
                buffer[0] =3D strlen(buffer+1);
                pstrcpy((char *)temp_string, (char *)buffer);
                =

        }else if (av.a_w.w_sym =3D=3D ps_blank_sym){
                pstrcpy((char *)temp_string, (char *)sub);

        }else if (!av.a_w.w_sym->s_name[0]){    =

                pstrcpy((char *)temp_string, (char *)sub);

        }else{          //it's a valid symbol and needs no conversion
                return(av.a_w.w_sym);
        }
                //if gets to here, it wasn't a valid symbol, so convert i=
t
        PtoCstr(temp_string);
        strcpy(temp_sym->s_name, (char*)temp_string);
        return(temp_sym);
}

Stephen Kay
---------------------- The MegaMAX Collection ----------------------
 Over 30 Max objects for the creation of more professional looking, =

         feeling, and functioning patchers and applications.
                     http://www.musikinetix.com
                         sk@musikinetix.com
--------------------------------------------------------------------

------------------------------

Date:    Thu, 6 Aug 1998 11:34:49 -0400
From:    Stephen Kay 
Subject: mtr

>Even with the tutorial patch, the playback has a flangy effect, like the=

midi
>data is being doubled.  Local control is off, but it shouldn't matter
anyway
>because mtr is just playing back what I put into it already.  This effec=
t
>happens in the patches I've made with mtr too.

>Any suggestions?  Does mtr typically have this problem?

mtr does not typically have this problem.  It sounds to me like you are
sending the data out multiple times, or your keyboard is receiving the
data mutiple times.  Check what output port the mtr is
sending to by clicking on whatever midiout or noteout object is being
used to send out the data.  I don't have the tutorial in front of me,
but those objects usually default to "all ports" if I'm not mistaken;
it's conceivable that your module or keyboard is receiving on more than
one port, or multiple channels, depending on your OMS setup.

Stephen Kay

------------------------------

Date:    Thu, 6 Aug 1998 08:53:10 -0700
From:    Jim Wood 
Subject: Re: MAX Digest - 4 Aug 1998 to 5 Aug 1998

Question;
When you send a Fullscreen comand to a thispatcher
object, why does it shove everything to the top left.
Is there a way of preventing this?
JimY.W
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

------------------------------

Date:    Thu, 6 Aug 1998 09:33:18 -0700
From:    David Zicarelli 
Subject: umenu

I'd be delighted to receive an example of some text, which when
typed into a umenu, causes it to go poof. I cannot for the life
of me accomplish this. If you type a semicolon into the text
box, it will disappear, but you could get around that with
backslash semicolon.

David Z.

------------------------------

Date:    Thu, 6 Aug 1998 09:47:44 -0700
From:    David Zicarelli 
Subject: Re: menubar and standalone applications.

Stephen Kay  writes:

>>1. Is there any way to remove "Status" from the Windows menu in a stand
>>alone application that uses menubar? I've tried ResEdit, but as far as I=
>
>>can see, the menubar menus does not show up in ResEdit.
>
>Yes.  This is undocumented, but in 3.5.x, you can send max a message
>which removes the status items, but only in a compiled app.  Now, I
>can't find this info anywhere, so I'm going by memory - maybe someone
>will correct me if I'm wrong, but type:
>
>;max status 1  (or is it 0)?

Stephen. I'm disappointed. I added this feature just for you, and
you can't even remember how to use it! The highly intuitive and
memorable magic incarnation is "maxinwmenu" as in "Max in the
windows menu." So...

; max maxinwmenu 0 will get rid of the Status item in the Windows
menu.

; max maxinwmenu 1 restores the Status item, or does nothing
if it's already there.

And while I'm on the subject, here are two new secret messages
to Max that you might find amusing. They work in 3.5.9 if not
earlier versions:

; max paths
; max externs

David Z.

------------------------------

Date:    Thu, 6 Aug 1998 19:08:25 +0200
From:    Peter Castine 
Subject: Re: floats' displayed precision?

On 6-8-1998 6:54, Burton Alexandre wrote about Max representing 11.8 as
11.799998:

>      Steele and White proposed a while ago: "When converting a value
>to a string, convert to the smallest number of digits such that converting
>back yields the original value again."
[schnipp]

> So my question, more direct (i admit my original post was a little on
>the vague side): how does one cope with the fact Max does not deal
>elegantly with (decimal) string representation *and* does not provide a
>formatting function? I'd really like to see 18.8.

Ahhhhhhhhhhhhh! Why didn't you say that the first time?

Response: someone has to develop a "smart" floating point number box as
an external object. (This could perhaps be done with a patcher, but the
overhead would, I think, be pretty humongous... alternately, some Pyrite
coding could handle this, but you'd need to dig in to Pyrite.).

I can't, off hand, think of any other solutions (aside from David doing
this to the built-in number box).

Cheers,

Peter -- whose responses also tune into what's been sent.

---------------- http://www.prz.tu-berlin.de/~pcastine/ ----------------
Dr. Peter Castine           | LAWYER, n.
pcastine@prz.tu-berlin.de   | One skilled in circumvention of the law.
                            |     -- Ambrose Bierce _Devil's Dictionary_

------------------------------

End of MAX Digest - 5 Aug 1998 to 6 Aug 1998
********************************************