kstrtodec64(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kstrtodec64(9)

okay bestie, welcome to the Kernel API Manual ✨ today we're looking at kstrtodec64 and honestly? she's iconic. this one converts a string into a signed 64-bit scaled decimal value and she does it flawlessly, no cap 🫢


✨ NAME ✨

kstrtodec64 β€” Convert a string to a signed 64-bit scaled decimal value. literally her whole personality πŸ’–


🌸 SYNOPSIS 🌸

int kstrtodec64 (const char *s , unsigned int scale , s64 *res );

πŸŽ€ ARGUMENTS πŸŽ€

  • s β€” the start of the string, bestie. she must be null-terminated, and she's also allowed to have a single newline sitting right before that terminating null (yes she's flexible like that πŸ’β€β™€οΈ). the very first character can also be a plus sign or a minus sign, so go off king πŸ‘‘
  • scale β€” the number of digits to the right of the decimal point. this is her main character number fr πŸ”₯
  • res β€” where the result of the conversion gets written when everything goes right. this is the spot where the slay gets delivered πŸ’Œ

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: a scale of 4 with the input "-3.141592" gives you -31415. that's it, that's the vibe ✨

and listen β€” digits beyond the specified scale are ignored πŸ™ˆ like, they simply don't make the cut. also, you do not need to pad in trailing zeros in the fractional part just to match the scale. she's low-maintenance, she's chill, she ate πŸ’…


⭐ RETURN ⭐

  • 0 on success πŸŽ‰
  • -ERANGE on overflow 😭
  • -EINVAL on parsing error πŸ’€

like, three outcomes and she's honest about all of them. we love a transparent queen 🌈


πŸ“ SEE ALSO πŸ“

the whole friend group!! go say hi to her sisters, they're all serving πŸ’œ


ngl bestie, if you're passing a string that isn't null-terminated, or you've got more than one sneaky newline chilling at the end, that's on you. the rules are the rules πŸ™ˆ

and that's the whole page, bestie!! this one lives in ./lib, dated October 2026, and she goes by kstrtodec64(9) πŸ’– mwah, go convert something iconic πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from