PSeInt Trunc: keep the whole part of a number
Cuts off the decimal part and keeps the whole part, without rounding.
- Group:
- Math Functions
- Template
Trunc
Opens the editor with this example loaded. Run it step by step and watch the flowchart.
Worked example
A complete algorithm, ready to copy and run.
Algoritmo Example Escribir Trunc(7.9)FinAlgoritmoOutput
Shows: 7 (it doesn't round up to 8)
This is what the console shows when the example runs.
7In a flowchart
This is how it appears in a flowchart, with the same shapes Codoritmo draws.
Template
The general form. Replace what's inside < > with your own data.
Trunc(<numero>)Examples that use it
Programs from the example library where it appears, from the simplest to the most complete.
Parking Fee
Charges every started hour, with a daily maximum.
IntermediateBinary Search
Finds a value in a sorted array by halving the range every step.
IntermediateLinear vs. Binary Search
Counts the comparisons each search needs on the same sorted list.
IntermediateGCD and LCM
Computes the greatest common divisor and the least common multiple.
IntermediateShell Sort
Insertion sort between far-apart elements, with a gap that shrinks every pass.
AdvancedMerge Sort
Splits the array in halves, sorts each one recursively and merges them.
Advanced
More math functions
Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.