text: #!/usr/bin/env python
  # encoding: utf-8
  #
  # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
  #
  """Checking the sign of a value.
  """
  #end_pymotw_header
  
  import math
  
  HEADINGS = ('f', 's', '< 0', '> 0', '= 0')
  print '{:^5}  {:^5}  {:^5}  {:^5}  {:^5}'.format(*HEADINGS)
  print '{:-^5}  {:-^5}  {:-^5}  {:-^5}  {:-^5}'.format(
      '', '', '', '', '',
      )
  
  for f in [ -1.0,
              0.0,
              1.0,
              float('-inf'),
              float('inf'),
              float('-nan'),
              float('nan'),
              ]:
      s = int(math.copysign(1, f))
      print '{:5.1f}  {:5d}  {!s:5}  {!s:5}  {!s:5}'.format(
          f, s, f < 0, f > 0, f==0,
          )
  