Permalink
Browse files

Handle nan/inf/-inf

  • Loading branch information...
1 parent 0925535 commit ed010b6ddeea67d45060188edf8e2f4747aa58ff Robert Newson committed Jul 12, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/main/scala/scalang/node/ScalaTermEncoder.scala
@@ -232,8 +232,16 @@ class ScalaTermEncoder(peer: Symbol) extends OneToOneEncoder with Logging with I
}
def writeFloat(buffer : ChannelBuffer, d : Double) {
- buffer.writeByte(70)
- buffer.writeLong(java.lang.Double.doubleToLongBits(d))
+ if (d.isNaN) {
+ writeAtom(buffer, 'nan)
+ } else if (d.isPosInfinity) {
+ writeAtom(buffer, 'infinity)
+ } else if (d.isNegInfinity) {
+ writeAtom(buffer, Symbol("-infinity"))
+ } else {
+ buffer.writeByte(70)
+ buffer.writeLong(java.lang.Double.doubleToLongBits(d))
+ }
}
def writeStringFloat(buffer : ChannelBuffer, d : Double) {

0 comments on commit ed010b6

Please sign in to comment.