diff options
author | Nicolas Williams <nico@cryptonector.com> | 2013-11-30 02:29:21 -0600 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2013-12-04 18:21:42 -0600 |
commit | ae7a042876130c471dce28a4396abc215192eaa9 (patch) | |
tree | 842a2f39da0c8394b293b6179022bd4981842cf2 | |
parent | eb165459aae82f0b5d25bc6e5132db501fa9e148 (diff) |
Make length return abs value of numeric inputs
-rw-r--r-- | builtin.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -287,6 +287,8 @@ static jv f_length(jv input) { return jv_number(jv_object_length(input)); } else if (jv_get_kind(input) == JV_KIND_STRING) { return jv_number(jv_string_length_codepoints(input)); + } else if (jv_get_kind(input) == JV_KIND_NUMBER) { + return jv_number(fabs(jv_number_value(input))); } else if (jv_get_kind(input) == JV_KIND_NULL) { jv_free(input); return jv_number(0); |