New Posts  All Forums:Forum Nav:

SQL Float Signage

post #1 of 4
Thread Starter 
Is there a predefined function that provides signage of an float?

I can always do IF statements but that's so inelegant.

If price is postive and principal is postive, par is positive.
If price is postive and principal is negative, par is negative.
If price is negative and principal is postive, par is negative.
If price is negative and principal is negative, par is positive.
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
post #2 of 4
Quote:
Originally Posted by DuckieHo View Post
Is there a predefined function that provides signage of an float?

I can always do IF statements but that's so inelegant.

If price is postive and principal is postive, par is positive.
If price is postive and principal is negative, par is negative.
If price is negative and principal is postive, par is negative.
If price is negative and principal is negative, par is positive.
http://dev.mysql.com/doc/refman/5.0/...mmary-ref.html

SIGN() :: Return the sign of the argument
post #3 of 4
Quote:
Originally Posted by DuckieHo View Post
Is there a predefined function that provides signage of an float?

I can always do IF statements but that's so inelegant.

If price is postive and principal is postive, par is positive.
If price is postive and principal is negative, par is negative.
If price is negative and principal is postive, par is negative.
If price is negative and principal is negative, par is positive.
I don't know much sql, but that's an xor relationship. Par sign = price sign ⊕ principal sign
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
post #4 of 4
Thread Starter 
Quote:
Originally Posted by Warhaven View Post
http://dev.mysql.com/doc/refman/5.0/...mmary-ref.html

SIGN() :: Return the sign of the argument
Thanks, that's it!

Quote:
Originally Posted by rabidgnome229 View Post
I don't know much sql, but that's an xor relationship. Par sign = price sign ⊕ principal sign
Yup, but I need the positive/negative signage applied to a value.

My query will include:
par = sign(price) * sign(principal) * abs(par)
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming