### Author Topic: More compact way for conditionless greater-than-zero  (Read 2493 times)

#### Gobo

• Bot Builder
• Posts: 67
##### More compact way for conditionless greater-than-zero
« on: November 27, 2007, 04:31:16 AM »
One may say
Code: [Select]
`sgn sqr`instead of generally adopted
Code: [Select]
`0 floor sgn`Ironically, there is a comment inside DB source code:
Code: [Select]
`'Returns square root of a positive number. Can't think of a specific use but it is valid.`It seems, a specific use is finally found

#### Trafalgar

• Bot Destroyer
• Posts: 122
##### More compact way for conditionless greater-than-zero
« Reply #1 on: May 13, 2008, 12:23:59 PM »
I wonder which of those is more efficient framerate-wise. Considering you're only ever sqrting -1, 0, or 1, if there are special cases in the code for 0, 1, and negative numbers, it shouldn't have the overhead of actually doing a sqrt. Hmm.

#### Numsgil

• Administrator
• Bot God
• Posts: 7717
##### More compact way for conditionless greater-than-zero
« Reply #2 on: May 13, 2008, 01:37:24 PM »
When I profiled the program years ago, other than vision and physics, the big CPU hog was just the overhead of switching from one base pair to the next.  The actual operations the base pairs perform are probably inconsequential by comparison.

#### gymsum

• Bot Destroyer
• Posts: 215
##### More compact way for conditionless greater-than-zero
« Reply #3 on: May 13, 2008, 10:32:14 PM »
does sqrt only work if you use 10+? sqrt of 1 is a floating decimal.

#### Trafalgar

• Bot Destroyer
• Posts: 122
##### More compact way for conditionless greater-than-zero
« Reply #4 on: May 14, 2008, 12:27:41 AM »
Quote from: gymsum
does sqrt only work if you use 10+? sqrt of 1 is a floating decimal.

What are you smoking? 1*1 = 1.

#### Numsgil

• Administrator
• Bot God
• Posts: 7717
##### More compact way for conditionless greater-than-zero
« Reply #5 on: May 14, 2008, 12:45:14 AM »
The sqr operator takes the square root of a number, then floors it.

That is, 99 sqr would give you 9.

Negative numbers return 0.

#### gymsum

• Bot Destroyer
• Posts: 215
##### More compact way for conditionless greater-than-zero
« Reply #6 on: May 14, 2008, 12:57:39 AM »
Quote from: Trafalgar
Quote from: gymsum
does sqrt only work if you use 10+? sqrt of 1 is a floating decimal.

What are you smoking? 1*1 = 1.
lol oh yeah