kstrtoudec64(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kstrtoudec64 πŸ’…

okay so bestie, welcome to kstrtoudec64 β€” the little kernel helper that takes a string and turns it into an unsigned 64-bit scaled decimal value. yes, that's the whole vibe. it's from the Kernel API Manual and honestly it ate. ✨


🌸 SYNOPSIS 🌸

int kstrtoudec64 (const char *s , unsigned int scale , u64 *res );

like, three args, no drama, she's lowkey iconic for that 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • s β€” the start of the string, bestie. it must be null-terminated, and it may also include a single newline before its terminating null (just the one, okay? don't get weird with it πŸ™ˆ). the first character may also be a plus sign β€” but not a minus sign. nope. no negatives here, this is unsigned erasure πŸ’€
  • scale β€” the number of digits to the right of the decimal point. that's it, that's the whole job ✨
  • res β€” where the result of the conversion gets written on success. it's the lil home for your answer πŸ πŸ’–

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so let's do the example, because the example eats:

a scale of 3 with input "123.45" results in 123450. iconic. no cap. πŸ”₯

and here's the tea: trailing zeros in the fractional part of the input, the ones you'd need to match the scale? not required. she's chill like that. 🧚

also β€” digits beyond the specified scale are ignored. literally just not invited to the party πŸ™…β€β™€οΈ


πŸ’œ RETURN πŸ’œ

  • 0 on success β€” slay πŸ’…
  • -ERANGE on overflow β€” she got too big for her boots 😭
  • -EINVAL on parsing error β€” the string showed up not knowing the assignment πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

go read them, iykyk 🌈⭐


and that's the page, bestie πŸŽ€ this one lives under ./lib, dated October 2026, and it's part of the Kernel API Manual β€” periodt. πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from