Skip to content

Commit

Permalink
faster string() and cstring() for signed integers
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 18, 2012
1 parent 4aba4d5 commit ec7571d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions j/string.j
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,9 @@ bits(x::Union(Int64,Uint64,Float64)) = bin(reinterpret(Uint64,x), 64)

num2hex(x::Integer) = hex(unsigned(x), sizeof(x)*2)

string(x::Signed) = dec(int64(x))
cstring(x::Signed) = dec(int64(x))

## string to float functions ##

function float64_isvalid(s::String, out::Array{Float64,1})
Expand Down

3 comments on commit ec7571d

@StefanKarpinski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this work for unsigned integers also?

@JeffBezanson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, but unsigned are currently printed in hex.

@StefanKarpinski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. Forgot about that.

Please sign in to comment.