Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: [OT(C)] float parameter treated as double by callee -- but it fails with FFI

by ikegami (Patriarch)
on Jul 01, 2021 at 23:10 UTC ( #11134573=note: print w/replies, xml ) Need Help??


in reply to Re^2: [OT(C)] float parameter treated as double by callee -- but it fails with FFI
in thread [OT(C)] float parameter treated as double by callee -- but it fails with FFI

That's why there's no printf length modifier for char, float or double.

signed char c = 123; int i = 123; float f = 123; double d = 123; printf("%d\n", i); // ok printf("%d\n", c); // ok, even though %d expects int. printf("%f\n", d); // ok printf("%f\n", f); // ok, even though %f expects double.

(Not sure why there's one for short since they are guaranteed to be no larger than an int and unsigned int respectively.)

Seeking work! You can reach me at ikegami@adaelis.com

Replies are listed 'Best First'.
Re^4: [OT(C)] float parameter treated as double by callee -- but it fails with FFI
by ikegami (Patriarch) on Jul 01, 2021 at 23:42 UTC

    There is one for char (hh).

    The reason it and the one for short (h) exists is purely for symmetry with scanf (which needs to know the type of object at the provided address).

    Seeking work! You can reach me at ikegami@adaelis.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11134573]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-09-29 15:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (125 votes). Check out past polls.

    Notices?