Path: utzoo!attcan!uunet!wuarchive!udel!mmdf From: mmdf@ee.udel.edu (The Mailer) Newsgroups: comp.os.minix Subject: Received: Message-ID: <30472@nigel.ee.udel.edu> Date: 14 Sep 90 16:40:35 GMT Organization: University of Delaware Lines: 68 Via: 000001013030.FTP.MAIL; 14 SEP 90 16:17:50 BST From: Dave Hines Date: Fri, 14 Sep 90 15:57:25 +0100 Message-Id: <26854.9009141457@uk.ac.dl.cxa> To: INFO-MINIX@udel.edu Cc: HBO043@djukfa11 In-Reply-To: Christoph van Wuellen's message of Mon, 10 Sep 90 17:36:31 GMT <24888.9009121930@uk.ac.dl.cxa Subject: arithmetic on enums & int square root Christoph, My vote would be to allow arithmetic on enums. This is consistent with the rest of C, which provides the power to do what you want, rather than trying to protect you from your own mistakes. This also appears to match the intent of the language... K&R says that enums may be declared giving a starting value to the series of integers to be used as the enum values. I can't think of any use for this feature unless enums can be used in the same places that integers can. In any case, thank you for making the c68 compiler available; may I contribute a small integer square root routine... I tried to send it to dale@syntel.uucp, for inclusion in the dLibs library, but received no response. (I suspect that my mail path was wrong). ################################ Cut Here ################################ /* * Integer square root. Returns the integer square root as the result of the * function, the remainder in the global long int result2. * * If x is an unsigned type, the square root of a full word will be generated. * Otherwise, a test for negative numbers should be added. (It doesn't matter * whether n, sub & tmp are signed or unsigned). * * Dave Hines, 1990. */ extern long result2; long lsqrt(x) long x; register long sub = 0; register long n = 0x40000000; /* Assuming 32 bit long */ register long tmp; do tmp = sub + n; sub >>= 1; if (tmp <= x) x -= tmp; sub += n; while (n >>= 2); result2 = x; return(sub); ################################## EOF ################################## Dave Hines. JANET: D.Hines@uk.ac.daresbury EARN/BITNET: D.Hines%daresbury.ac.uk@UKACRL UUCP: D.Hines%daresbury.ac.uk@ukc.uucp Ean: D.Hines%daresbury.ac.uk@ean-relay.ac.uk Internet: D.Hines%daresbury.ac.uk or D.Hines%daresbury@nsfnet-relay.ac.uk