static ssize_t iio_format_avail_range(char *buf, const int *vals, int type)
 {
-       return iio_format_list(buf, vals, type, 3, "[", "]");
+       int length;
+
+       /*
+        * length refers to the array size , not the number of elements.
+        * The purpose is to print the range [min , step ,max] so length should
+        * be 3 in case of int, and 6 for other types.
+        */
+       switch (type) {
+       case IIO_VAL_INT:
+               length = 3;
+               break;
+       default:
+               length = 6;
+               break;
+       }
+
+       return iio_format_list(buf, vals, type, length, "[", "]");
 }
 
 static ssize_t iio_read_channel_info_avail(struct device *dev,