Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

How do I wrote floor() without boolean logic?

Name: Anonymous 2006-02-19 14:55

How do I write a floor function without using boolean logic?

Name: Anonymous 2006-02-19 14:56

DEVIDE BY ZERO!

Name: Anonymous 2006-02-20 2:44

Use mod?  floor(a) = a - mod(a,1)

Name: Anonymous 2006-02-20 3:17

int floor(double a)
{
    (int)a;
}

Name: Anonymous 2006-02-20 3:25 (sage)

Oops, forgot the return statement, but you get the idea.

Name: Anonymous 2006-02-20 13:09

OK, how do you write int() or mod() without boolean logic?

Name: Anonymous 2006-02-20 14:16 (sage)

>>6
If someone says "use floor" I'll bust their fucking head.

Name: Anonymous 2006-02-20 14:21 (sage)

>>6
Use floor.

>>7
Just try. Oh yeah, that's right... you can't.

Name: Anonymous 2006-02-20 14:32 (sage)

gb2/prog/

Name: Anonymous 2006-02-20 16:51

>>9
Maybe if it was a programing question.

Name: Anonymous 2006-02-21 2:21

>>10

Surprise!  It is a programming question!

Name: Anonymous 2006-02-21 3:37

You've got to start with some axioms. In computing int() can be considered an axiom because it relies on the hardware implementation. Doesn't need logic as such, you just dump the non-integral part.

In maths the axioms are usually considered to be logic and set theory, so if you want to reduce the problem down to the axioms but you don't want to use logic, well, that's not gonna happen.

Name: Anonymous 2006-02-22 1:32

>>12
proof

Name: Anonymous 2006-02-22 3:22

>>13
You want me to prove my axioms? GTFO.

Name: Anonymous 2006-02-22 4:34

>>14
Prove your axioms.

Name: Anonymous 2006-02-22 7:33

>>13
>>15
Looks like SOME people don't understand the idea of axioms.

Name: Anonymous 2006-02-22 16:50

>>16
I was proving your mother's axioms all last night. _In the butt_.

Name: Anonymous 2006-02-22 17:21

>>17
BUIYY AXIOMS??/

Name: Anonymous 2006-02-23 0:29

First axiom of anonian algebra: Your mother is a whore.

Name: Anonymous 2006-02-23 11:24

>>4

That's wrong. floor(-5.6) ought to return -6, but (int)(-5.6) returns -5.

Name: Anonymous 2006-02-23 11:25

>>19
Prove your za warudo

Name: Anonymous 2006-02-28 2:37

floor(x) = -ceiling(-x)
Done without boolean logic. Now just come up with ceiling without boolean logic and you win ;)

Name: Anonymous 2006-03-01 1:06

int floor(double a)
{
  double x = abs(a);
  x = int(x);
  a = a + 2x;
  int(a);
  a = a - 2x;
  return a;
}
 

Name: Anonymous 2006-03-01 7:51

>>23
Oh shi...

Name: Anonymous 2006-03-02 19:07

>>23
abs() uses boolean logic

FAILED

Name: Anonymous 2006-03-02 19:12

here kids:


Absolute Value of a Float

IEEE floating point uses an explicit sign bit, so the absolute value can be taken by a bitwise AND with the complement of the sign bit. For IA32 32-bit, the sign bit is an int value of 0x80000000, for IA32 64-bit, the sign bit is the long long int value 0x8000000000000000. Of course, if you prefer to use just int values, the IA32 64-bit sign bit is 0x80000000 at an int address offset of +1. For example:

double x;

/* make x = abs(x) */
*(((int *) &x) + 1) &= 0x7fffffff;

Name: Anonymous 2006-03-02 20:28

OMG BITWISE IS BOOLEAN OPERATER FAPFAPFAP

Name: Anonymous 2006-03-03 7:01

>>27
is not

Name: Anonymous 2006-03-03 10:55 (sage)

>>27
In that case, every CPU is based on bitwise operations, so it's impossible.

Name: Anonymous 2006-03-03 12:30

>>29
We must then ask the quantum computer that works sometimes even though it isn't turned on

Don't change these.
Name: Email:
Entire Thread Thread List