in reply to Re: Length of float using printf
in thread Length of float using printf

I want to use printf only as my application uses printf and stores the format type in the object. The reason I want to represent 40000 as 4000 as it is incorrect if somebody is passing 40000. My object can't figure that out. It is for error handling.

Replies are listed 'Best First'.
Re^3: Length of float using printf
by ikegami (Patriarch) on Jun 02, 2009 at 18:47 UTC

    printf doesn't chop anything except the decimal portion. It makes sense since 40000 means something very different than 4000 (left-chopped) or 0000 (right-chopped), while 5.123 and 5.12 are similar.

    You can still use printf, but you first need to chop it using substr, unpack or some other means.